If the node has a content object attached, the property will be checked
there.
public hasProperty ( string $propertyName ) : boolean | ||
$propertyName | string | Name of the property to test for |
return | boolean |
/** * Sets the best possible uriPathSegment for the given Node. * Will use an already set uriPathSegment or alternatively the node name as base, * then checks if the uriPathSegment already exists on the same level and appends a counter until a unique path segment was found. * * @param NodeInterface $node * @return void */ public static function setUniqueUriPathSegment(NodeInterface $node) { if ($node->getNodeType()->isOfType('Neos.Neos:Document')) { $q = new FlowQuery(array($node)); $q = $q->context(array('invisibleContentShown' => true, 'removedContentShown' => true, 'inaccessibleContentShown' => true)); $possibleUriPathSegment = $initialUriPathSegment = !$node->hasProperty('uriPathSegment') ? $node->getName() : $node->getProperty('uriPathSegment'); $i = 1; while ($q->siblings('[instanceof Neos.Neos:Document][uriPathSegment="' . $possibleUriPathSegment . '"]')->count() > 0) { $possibleUriPathSegment = $initialUriPathSegment . '-' . $i++; } $node->setProperty('uriPathSegment', $possibleUriPathSegment); } }
/** * Renders a request path based on the "uriPathSegment" properties of the nodes leading to the given node. * * @param NodeInterface $node The node where the generated path should lead to * @return string A relative request path * @throws Exception\MissingNodePropertyException if the given node doesn't have a "uriPathSegment" property set */ protected function getRequestPathByNode(NodeInterface $node) { if ($node->getParentPath() === SiteService::SITES_ROOT_PATH) { return ''; } $requestPathSegments = []; while ($node instanceof NodeInterface && $node->getParentPath() !== SiteService::SITES_ROOT_PATH) { if (!$node->hasProperty('uriPathSegment')) { throw new Exception\MissingNodePropertyException(sprintf('Missing "uriPathSegment" property for node "%s". Nodes can be migrated with the "flow node:repair" command.', $node->getPath()), 1415020326); } $pathSegment = $node->getProperty('uriPathSegment'); $requestPathSegments[] = $pathSegment; $node = $node->getParent(); } return implode('/', array_reverse($requestPathSegments)); }