class FrontendNodeRoutePartHandler extends DynamicRoutePart implements FrontendNodeRoutePartHandlerInterface (View source)

A route part handler for finding nodes specifically in the website's frontend.

Constants

DIMENSION_REQUEST_PATH_MATCHER

Properties

protected LoggerInterface $systemLogger
protected ContentContextFactory $contextFactory
protected Context $securityContext
protected DomainRepository $domainRepository
protected SiteRepository $siteRepository
protected bool $supportEmptySegmentForDimensions
protected ContentDimensionPresetSourceInterface $contentDimensionPresetSource
protected NodeShortcutResolver $nodeShortcutResolver
protected Site[] $siteByHostRuntimeCache

Methods

string
findValueToMatch(string $requestPath)

Extracts the node path from the request path.

bool|MatchResult
matchValue(string $requestPath)

Matches a frontend URI pointing to a node (for example a page).

convertRequestPathToNode(string $requestPath)

Returns the initialized node that is referenced by $requestPath, based on the node's "uriPathSegment" property.

bool|ResolveResult
resolveValue(NodeInterface|string|string[] $node)

Checks, whether given value is a Node object and if so, sets $this->value to the respective node path.

false|string|null
truncateUriPathSuffix(string $uriPath)

Removes the configured suffix from the given $uriPath If the "uriPathSuffix" option is not set (or set to an empty string) the unaltered $uriPath is returned

resolveShortcutNode(NodeInterface $node)

No description

UriConstraints
buildUriConstraintsForResolvedNode(NodeInterface $node)

Builds UriConstraints for the given $node with:

  • domain specific constraints for nodes in a different Neos site
  • a path suffix corresponding to the configured "uriPathSuffix"

UriConstraints
applyDomainToUriConstraints(UriConstraints $uriConstraints, Domain|null $domain)

No description

buildContextFromRequestPath(string $requestPath)

Creates a content context from the given request path, considering possibly mentioned content dimension values.

buildContextFromPath(string $path, bool $convertLiveDimensions)

Creates a content context from the given "context path", i.e. a string used for resolving (not matching) a node.

buildContextFromWorkspaceName(string $workspaceName, array $dimensions = null)

No description

string
removeContextFromPath(string $path)

No description

bool
onlyMatchSiteNodes()

Whether the current route part should only match/resolve site nodes (e.g. the homepage)

bool
nodeTypeIsAllowed(NodeInterface $node)

Whether the given $node is allowed according to the "nodeType" option

string
resolveRoutePathForNode(NodeInterface $node)

Resolves the request path, also known as route path, identifying the given node.

string
getRelativeNodePathByUriPathSegmentProperties(NodeInterface $siteNode, string $relativeRequestPath)

Builds a node path which matches the given request path.

string
getRequestPathByNode(NodeInterface $node)

Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.

array
parseDimensionsAndNodePathFromRequestPath(string $requestPath)

Choose between default method for parsing dimensions or the one which allows uriSegment to be empty for default preset.

array
parseDimensionsAndNodePathFromRequestPathAllowingEmptySegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

array
parseDimensionsAndNodePathFromRequestPathAllowingNonUniqueSegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

buildContextFromWorkspaceNameAndDimensions(string $workspaceName, array $dimensionsAndDimensionValues)

Sets context properties like "invisibleContentShown" according to the workspace (live or not) and returns a ContentContext object.

getCurrentSite()

Determines the currently active site based on the "requestUriHost" parameter (that has to be set via HTTP middleware)

getSiteByHostName(string $hostName)

Returns a site matching the given $hostName

string
getUriSegmentForDimensions(array $dimensionsValues, bool $currentNodeIsSiteNode)

Find a URI segment in the content dimension presets for the given "language" dimension values

Details

protected string findValueToMatch(string $requestPath)

Extracts the node path from the request path.

Parameters

string $requestPath

The request path to be matched

Return Value

string

value to match, or an empty string if $requestPath is empty or split string was not found

protected bool|MatchResult matchValue(string $requestPath)

Matches a frontend URI pointing to a node (for example a page).

This function tries to find a matching node by the given request path. If one was found, its absolute context node path is set in $this->value and true is returned.

Note that this matcher does not check if access to the resolved workspace or node is allowed because at the point in time the route part handler is invoked, the security framework is not yet fully initialized.

Parameters

string $requestPath

The request path (without leading "/", relative to the current Site Node)

Return Value

bool|MatchResult

An instance of MatchResult if the route matches the $requestPath, otherwise FALSE. DynamicRoutePart::matchValue()

Exceptions

Exception
NoHomepageException

protected NodeInterface convertRequestPathToNode(string $requestPath)

Returns the initialized node that is referenced by $requestPath, based on the node's "uriPathSegment" property.

Note that $requestPath will be modified (passed by reference) by buildContextFromRequestPath().

Parameters

string $requestPath

The request path, for example /the/node/path@some-workspace

Return Value

NodeInterface

Exceptions

NoWorkspaceException
NoSiteException
NoSuchNodeException
NoSiteNodeException
InvalidRequestPathException

protected bool|ResolveResult resolveValue(NodeInterface|string|string[] $node)

Checks, whether given value is a Node object and if so, sets $this->value to the respective node path.

In order to render a suitable frontend URI, this function strips off the path to the site node and only keeps the actual node path relative to that site node. In practice this function would set $this->value as follows:

absolute node path: /sites/neostypo3org/homepage/about $this->value: homepage/about

absolute node path: /sites/neostypo3org/homepage/about@user-admin $this->value: homepage/about@user-admin

Parameters

NodeInterface|string|string[] $node

Either a Node object or an absolute context node path (potentially wrapped in an array as ['__contextNodePath' => ''])

Return Value

bool|ResolveResult

An instance of ResolveResult if the route coulr resolve the $node, otherwise FALSE. DynamicRoutePart::resolveValue()

Exceptions

NoSiteException

See also

NodeIdentityConverterAspect

protected false|string|null truncateUriPathSuffix(string $uriPath)

Removes the configured suffix from the given $uriPath If the "uriPathSuffix" option is not set (or set to an empty string) the unaltered $uriPath is returned

Parameters

string $uriPath

Return Value

false|string|null

Exceptions

InvalidRequestPathException

protected NodeInterface|Uri resolveShortcutNode(NodeInterface $node)

No description

Parameters

NodeInterface $node

Return Value

NodeInterface|Uri

The original, unaltered $node if it's not a shortcut node. Otherwise the nodes shortcut target (a node or an URI for external & asset shortcuts)

Exceptions

InvalidShortcutException

protected UriConstraints buildUriConstraintsForResolvedNode(NodeInterface $node)

Builds UriConstraints for the given $node with:

  • domain specific constraints for nodes in a different Neos site
  • a path suffix corresponding to the configured "uriPathSuffix"

Parameters

NodeInterface $node

Return Value

UriConstraints

Exceptions

NoSiteException

protected UriConstraints applyDomainToUriConstraints(UriConstraints $uriConstraints, Domain|null $domain)

No description

Parameters

UriConstraints $uriConstraints
Domain|null $domain

Return Value

UriConstraints

protected ContentContext buildContextFromRequestPath(string $requestPath)

Creates a content context from the given request path, considering possibly mentioned content dimension values.

Parameters

string $requestPath

The request path. If at least one content dimension is configured, the first path segment will identify the content dimension values

Return Value

ContentContext

The built content context

protected ContentContext buildContextFromPath(string $path, bool $convertLiveDimensions)

Creates a content context from the given "context path", i.e. a string used for resolving (not matching) a node.

Parameters

string $path

a path containing the context, such as /sites/examplecom/home@user-johndoe or /assets/pictures/my-picture or /assets/pictures/my-picture@user-john;language=de&country=global

bool $convertLiveDimensions

Whether to parse dimensions from the context path in a non-live workspace

Return Value

ContentContext

based on the specified path; only evaluating the context information (i.e. everything after "@")

Exceptions

InvalidRequestPathException

protected ContentContext buildContextFromWorkspaceName(string $workspaceName, array $dimensions = null)

No description

Parameters

string $workspaceName
array $dimensions

Return Value

ContentContext

Exceptions

NoSiteException

protected string removeContextFromPath(string $path)

No description

Parameters

string $path

an absolute or relative node path which possibly contains context information, for example "/sites/somesite/the/node/path@some-workspace"

Return Value

string

the same path without context information

protected bool onlyMatchSiteNodes()

Whether the current route part should only match/resolve site nodes (e.g. the homepage)

Return Value

bool

protected bool nodeTypeIsAllowed(NodeInterface $node)

Whether the given $node is allowed according to the "nodeType" option

Parameters

NodeInterface $node

Return Value

bool

protected string resolveRoutePathForNode(NodeInterface $node)

Resolves the request path, also known as route path, identifying the given node.

A path is built, based on the uri path segment properties of the parents of and the given node itself. If content dimensions are configured, the first path segment will the identifiers of the dimension values according to the current context.

Parameters

NodeInterface $node

The node where the generated path should lead to

Return Value

string

The relative route path, possibly prefixed with a segment for identifying the current content dimension values

protected string getRelativeNodePathByUriPathSegmentProperties(NodeInterface $siteNode, string $relativeRequestPath)

Builds a node path which matches the given request path.

This method traverses the segments of the given request path and tries to find nodes on the current level which have a matching "uriPathSegment" property. If no node could be found which would match the given request path, false is returned.

Parameters

NodeInterface $siteNode

The site node, used as a starting point while traversing the tree

string $relativeRequestPath

The request path, relative to the site's root path

Return Value

string

Exceptions

NoSuchNodeException

protected string getRequestPathByNode(NodeInterface $node)

Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node.

Parameters

NodeInterface $node

The node where the generated path should lead to

Return Value

string

A relative request path

Exceptions

MissingNodePropertyException

protected array parseDimensionsAndNodePathFromRequestPath(string $requestPath)

Choose between default method for parsing dimensions or the one which allows uriSegment to be empty for default preset.

Parameters

string $requestPath

The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"

Return Value

array

An array of dimension name => dimension values (array of string)

protected array parseDimensionsAndNodePathFromRequestPathAllowingEmptySegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

Allows uriSegment to be empty for default dimension preset.

If the first path segment contained content dimension information, it is removed from &$requestPath.

Parameters

string $requestPath

The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"

Return Value

array

An array of dimension name => dimension values (array of string)

Exceptions

InvalidDimensionPresetCombinationException

protected array parseDimensionsAndNodePathFromRequestPathAllowingNonUniqueSegment(string $requestPath)

Parses the given request path and checks if the first path segment is one or a set of content dimension preset identifiers. If that is the case, the return value is an array of dimension names and their preset URI segments.

Doesn't allow empty uriSegment, but allows uriSegment to be not unique across presets.

If the first path segment contained content dimension information, it is removed from &$requestPath.

Parameters

string $requestPath

The request path currently being processed by this route part handler, e.g. "de_global/startseite/ueber-uns"

Return Value

array

An array of dimension name => dimension values (array of string)

Exceptions

InvalidDimensionPresetCombinationException
InvalidRequestPathException
NoSuchDimensionValueException

protected ContentContext buildContextFromWorkspaceNameAndDimensions(string $workspaceName, array $dimensionsAndDimensionValues)

Sets context properties like "invisibleContentShown" according to the workspace (live or not) and returns a ContentContext object.

Parameters

string $workspaceName

Name of the workspace to use in the context

array $dimensionsAndDimensionValues

An array of dimension names (index) and their values (array of strings). See also: ContextFactory

Return Value

ContentContext

Exceptions

NoSiteException

protected Site getCurrentSite()

Determines the currently active site based on the "requestUriHost" parameter (that has to be set via HTTP middleware)

Return Value

Site

Exceptions

NoSiteException

protected Site getSiteByHostName(string $hostName)

Returns a site matching the given $hostName

Parameters

string $hostName

Return Value

Site

Exceptions

NoSiteException

protected string getUriSegmentForDimensions(array $dimensionsValues, bool $currentNodeIsSiteNode)

Find a URI segment in the content dimension presets for the given "language" dimension values

This will do a reverse lookup from actual dimension values to a preset and fall back to the default preset if none can be found.

Parameters

array $dimensionsValues

An array of dimensions and their values, indexed by dimension name

bool $currentNodeIsSiteNode

If the current node is actually the site node

Return Value

string

Exceptions

Exception