Skip to content

Commit

Permalink
TASK: Further improve comments and exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed May 28, 2024
1 parent c34eb9b commit 95f1c5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ public function resolveWithParameters(array &$routeValues, RouteParameters $para

try {
$resolveResult = $this->resolveNodeAddress($nodeAddress, $currentRequestSiteDetectionResult->siteNodeName);
} catch (NodeNotFoundException | InvalidShortcutException $exception) {
// TODO log exception
} catch (NodeNotFoundException | TargetSiteNotFoundException | InvalidShortcutException $exception) {
// TODO log exception ... yes todo
return false;
}

Expand All @@ -288,6 +288,7 @@ public function resolveWithParameters(array &$routeValues, RouteParameters $para
*
* @throws InvalidShortcutException
* @throws NodeNotFoundException
* @throws TargetSiteNotFoundException
*/
private function resolveNodeAddress(
NodeAddress $nodeAddress,
Expand Down
22 changes: 20 additions & 2 deletions Neos.Neos/Classes/FrontendRouting/NodeUri/NodeUriBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
/**
* Neos abstraction to simplify node uri building.
*
* Builds URIs to nodes, taking workspace (live / shared / user) into account.
* Can also be used in order to render "preview" URLs to nodes, that are not
* in the live workspace (in the Neos Backend and shared workspaces)
*
* Internally a Flow route is configured using the {@see EventSourcedFrontendNodeRoutePartHandler}.
* Streamlines the uri building to not having to interact with the {@see UriBuilder} or having to serialize the node address.
*
Expand Down Expand Up @@ -80,6 +84,11 @@ public function __construct(
*
* Host relative urls are build by default for non cross-linked nodes.
*
* Shortcut nodes
* --------------
*
* Resolving a uri for a shortcut node will result in the url pointing to the shortcut target (node, asset or external URI).
*
* Supported options
* -----------------
*
Expand All @@ -105,14 +114,23 @@ public function __construct(
* );
*
* @api
* @throws NoMatchingRouteException in the unlike case the default route definition is misconfigured,
* or more likely in combination with custom options but no backing route defined.
* @throws NoMatchingRouteException
* The exception is thrown for various unlike cases in which uri building fails:
* - the default route definitions are misconfigured
* - the custom uri building options don't macht a route
* - the shortcut points to an invalid target
* - the live node address cannot be found in the projection
* Please consult the logs for further information.
*/
public function uriFor(NodeAddress $nodeAddress, Options $options = null): UriInterface
{
$options ??= Options::create();

if (!$nodeAddress->workspaceName->isLive()) {
// we cannot build a human-readable uri using the showAction as
// the DocumentUriPathProjection only handles the live workspace
// now we fall back to building an absolute preview uri ignoring all possible options, because they are not applicable.
// (e.g. otherwise one would need to define a custom json route also for the previewAction which is unlikely considered and untested)
return $this->previewUriFor($nodeAddress);
}

Expand Down

0 comments on commit 95f1c5e

Please sign in to comment.