Skip to content

Commit

Permalink
TASK: RenderingMode followup
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Feb 6, 2024
1 parent be25608 commit e3ff7a4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
15 changes: 8 additions & 7 deletions Neos.Neos/Classes/Controller/Frontend/NodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
use Neos\Neos\Utility\NodeTypeWithFallbackProvider;
use Neos\Neos\View\FusionView;

/**
* Event Sourced Node Controller; as Replacement of NodeController
*/
class NodeController extends ActionController
{
use NodeTypeWithFallbackProvider;
Expand Down Expand Up @@ -110,7 +107,7 @@ class NodeController extends ActionController
protected int $shortcutRedirectHttpStatusCode;

/**
* @param string $node Legacy name for backwards compatibility of route components
* @param string $node
* @throws NodeNotFoundException
* @throws \Neos\Flow\Mvc\Exception\StopActionException
* @throws \Neos\Flow\Mvc\Routing\Exception\MissingActionNameException
Expand Down Expand Up @@ -157,7 +154,11 @@ public function previewAction(string $node): void
);
}

if ($this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT) && $nodeAddress->isInLiveWorkspace()) {
if (
$this->getNodeType($nodeInstance)->isOfType(NodeTypeNameFactory::NAME_SHORTCUT)
&& !$renderingMode->isEdit
&& $nodeAddress->workspaceName->isLive() // shortcuts are only resolvable for the live workspace
) {
$this->handleShortcutNode($nodeAddress, $contentRepository);
}

Expand All @@ -168,7 +169,7 @@ public function previewAction(string $node): void
'site' => $site,
]);

if (!$nodeAddress->isInLiveWorkspace()) {
if ($renderingMode->isEdit) {
$this->overrideViewVariablesFromInternalArguments();
$this->response->setHttpHeader('Cache-Control', 'no-cache');
if (!$this->view->canRenderWithNodeAndPath()) {
Expand Down Expand Up @@ -266,7 +267,7 @@ protected function overrideViewVariablesFromInternalArguments()
}

/**
* Handles redirects to shortcut targets in live rendering.
* Handles redirects to shortcut targets of nodes in the live workspace.
*
* @param NodeAddress $nodeAddress
* @throws NodeNotFoundException
Expand Down
9 changes: 4 additions & 5 deletions Neos.Neos/Classes/Domain/Model/RenderingMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
* Describes the mode in which the Neos interface is rendering currently,
* mainly distinguishing between edit and preview modes currently.
*/
class RenderingMode
final class RenderingMode
{
public const FRONTEND = 'frontend';

/**
* @param array<string,mixed> $options
*/
public function __construct(
private function __construct(
public readonly string $name,
public readonly bool $isEdit,
public readonly bool $isPreview,
Expand All @@ -52,23 +52,22 @@ public static function createFromConfiguration(string $modeName, array $configur
1694802951840
);
}
$mode = new RenderingMode(
return new self(
$modeName,
$configuration['isEditingMode'] ?? false,
$configuration['isPreviewMode'] ?? false,
$configuration['title'] ?? $modeName,
$configuration['fusionRenderingPath'] ?? '',
$configuration['options'] ?? [],
);
return $mode;
}

/**
* Creates the system integrated rendering mode 'frontend'
*/
public static function createFrontend(): RenderingMode
{
return new RenderingMode(
return new self(
RenderingMode::FRONTEND,
false,
false,
Expand Down
3 changes: 3 additions & 0 deletions Neos.Neos/Classes/FrontendRouting/NodeShortcutResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public function __construct(
*/
public function resolveShortcutTarget(NodeAddress $nodeAddress, ContentRepository $contentRepository)
{
if (!$nodeAddress->workspaceName->isLive()) {
throw new \RuntimeException(sprintf('Cannot resolve shortcut target for node-address %s in workspace %s because the DocumentUriPathProjection only handles the live workspace.', $nodeAddress->nodeAggregateId->value, $nodeAddress->workspaceName->value), 1707208650);
}
$documentUriPathFinder = $contentRepository->projectionState(DocumentUriPathFinder::class);
$documentNodeInfo = $documentUriPathFinder->getByIdAndDimensionSpacePointHash(
$nodeAddress->nodeAggregateId,
Expand Down

0 comments on commit e3ff7a4

Please sign in to comment.