Skip to content

Commit

Permalink
TASK: Remove unnecessary redirect for yoast preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebobo committed Apr 8, 2020
1 parent 94efa95 commit 8dca18b
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions Classes/Controller/PageController.php
Expand Up @@ -22,33 +22,25 @@
class PageController extends ActionController
{

/** w
/**
* Redirects request to the given node in preview mode without the neos backend
*
* @param NodeInterface $node
* @throws StopActionException
*/
public function renderPreviewPageAction(NodeInterface $node): void
{
if (method_exists($this->response, 'setComponentParameter')) {
/** @noinspection PhpUndefinedClassInspection */
/** @noinspection PhpUndefinedNamespaceInspection */
$this->response->setComponentParameter(Neos\Flow\Http\Component\SetHeaderComponent::class, 'Cache-Control', [
'no-cache',
'no-store'
]);
} else {
/** @noinspection PhpUndefinedMethodInspection */
$this->response->getHeaders()->setCacheControlDirective('no-cache');
$previewAction = 'preview';

# Neos 5.x uses the 'preview' action which also sets cache headers
# So for Neos 4.x we have to add the cache headers and use the 'show' action
if (!method_exists(NodeController::class, 'previewAction')) {
$previewAction = 'show';
/** @noinspection PhpUndefinedMethodInspection */
$this->response->getHeaders()->setCacheControlDirective('no-store');
$this->response->getHeaders()->setCacheControlDirective('no-cache, no-store, must-revalidate');
}

$previewAction = 'show';
if (method_exists(NodeController::class, 'previewAction')) {
$previewAction = 'preview';
}
$this->redirect($previewAction, 'Frontend\Node', 'Neos.Neos', [
$this->forward($previewAction, 'Frontend\Node', 'Neos.Neos', [
'node' => $node,
'yoastSeoPreviewMode' => true,
]);
Expand Down

0 comments on commit 8dca18b

Please sign in to comment.