class LinkingService (View source)

A service for creating URIs pointing to nodes and assets.

The target node can be provided as string or as a Node object; if not specified at all, the generated URI will refer to the current document node inside the Fusion context.

When specifying the node argument as string, the following conventions apply:

node starts with /: The given path is an absolute node path and is treated as such. Example: /sites/acmecom/home/about/us

node does not start with /: The given path is treated as a path relative to the current node. Examples: given that the current node is /sites/acmecom/products/, stapler results in /sites/acmecom/products/stapler, ../about results in /sites/acmecom/about/, ./neos/info results in /sites/acmecom/products/neos/info.

node starts with a tilde character (~): The given path is treated as a path relative to the current site node. Example: given that the current node is /sites/acmecom/products/, ~/about/us results in /sites/acmecom/about/us, ~ results in /sites/acmecom.

Constants

PATTERN_SUPPORTED_URIS

Pattern to match supported URIs.

Properties

protected AssetRepository $assetRepository
protected ResourceManager $resourceManager
protected NodeShortcutResolver $nodeShortcutResolver
protected PropertyMapper $propertyMapper
protected NodeInterface $lastLinkedNode
protected LoggerInterface $systemLogger
protected NeosNodeServiceInterface $nodeService
protected SiteRepository $siteRepository
protected BaseUriProvider $baseUriProvider

Methods

bool
hasSupportedScheme(string|UriInterface $uri)

No description

string
getScheme(string|UriInterface $uri)

No description

string|null
resolveNodeUri(string $uri, NodeInterface $contextNode, ControllerContext $controllerContext, bool $absolute = false)

Resolves a given node:// URI to a "normal" HTTP(S) URI for the addressed node.

string|null
resolveAssetUri(string $uri)

Resolves a given asset:// URI to a "normal" HTTP(S) URI for the addressed asset's resource.

convertUriToObject(string|UriInterface $uri, NodeInterface $contextNode = null)

Return the object the URI addresses or NULL.

string
createNodeUri(ControllerContext $controllerContext, mixed $node = null, NodeInterface $baseNode = null, string $format = null, bool $absolute = false, array $arguments = [], string $section = '', bool $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], bool $resolveShortcuts = true)

Renders the URI to a given node instance or -path.

string
createSiteUri(ControllerContext $controllerContext, Site $site)

No description

NodeInterface|null
getLastLinkedNode()

Returns the node that was last used to resolve a link to.

Details

bool hasSupportedScheme(string|UriInterface $uri)

No description

Parameters

string|UriInterface $uri

Return Value

bool

string getScheme(string|UriInterface $uri)

No description

Parameters

string|UriInterface $uri

Return Value

string

string|null resolveNodeUri(string $uri, NodeInterface $contextNode, ControllerContext $controllerContext, bool $absolute = false)

Resolves a given node:// URI to a "normal" HTTP(S) URI for the addressed node.

Parameters

string $uri
NodeInterface $contextNode
ControllerContext $controllerContext
bool $absolute

Return Value

string|null

If the node cannot be resolved, null is returned

Exceptions

Exception
MissingActionNameException
Exception
Exception

string|null resolveAssetUri(string $uri)

Resolves a given asset:// URI to a "normal" HTTP(S) URI for the addressed asset's resource.

Parameters

string $uri

Return Value

string|null

If the URI cannot be resolved, null is returned

NodeInterface|AssetInterface|null convertUriToObject(string|UriInterface $uri, NodeInterface $contextNode = null)

Return the object the URI addresses or NULL.

Parameters

string|UriInterface $uri
NodeInterface $contextNode

Return Value

NodeInterface|AssetInterface|null

string createNodeUri(ControllerContext $controllerContext, mixed $node = null, NodeInterface $baseNode = null, string $format = null, bool $absolute = false, array $arguments = [], string $section = '', bool $addQueryString = false, array $argumentsToBeExcludedFromQueryString = [], bool $resolveShortcuts = true)

Renders the URI to a given node instance or -path.

Parameters

ControllerContext $controllerContext
mixed $node

A node object or a string node path, if a relative path is provided the baseNode argument is required

NodeInterface $baseNode
string $format

Format to use for the URL, for example "html" or "json"

bool $absolute

If set, an absolute URI is rendered

array $arguments

Additional arguments to be passed to the UriBuilder (for example pagination parameters)

string $section
bool $addQueryString

If set, the current query parameters will be kept in the URI

array $argumentsToBeExcludedFromQueryString

arguments to be removed from the URI. Only active if $addQueryString = true

bool $resolveShortcuts

@deprecated With Neos 7.0 this argument is no longer evaluated and log a message if set to FALSE

Return Value

string

The rendered URI

Exceptions

Exception
MissingActionNameException
Exception
Exception
Exception
IllegalObjectTypeException

string createSiteUri(ControllerContext $controllerContext, Site $site)

No description

Parameters

ControllerContext $controllerContext
Site $site

Return Value

string

Exceptions

Exception
Exception

NodeInterface|null getLastLinkedNode()

Returns the node that was last used to resolve a link to.

May return NULL in case no link has been generated or an error occurred on the last linking run.

Return Value

NodeInterface|null