Example: /sites/mysitecom/homepage/about@user-admin
public getContextPath ( ) : string | ||
Résultat | string | Node path with context information |
/** * @param NodeInterface $node * @param boolean $expand * @param array $children * @param boolean $hasChildNodes * @param boolean $matched * @return array */ public function collectTreeNodeData(NodeInterface $node, $expand = true, array $children = array(), $hasChildNodes = false, $matched = false) { $isTimedPage = false; $now = new \DateTime(); $now = $now->getTimestamp(); $hiddenBeforeDateTime = $node->getHiddenBeforeDateTime(); $hiddenAfterDateTime = $node->getHiddenAfterDateTime(); if ($hiddenBeforeDateTime !== null && $hiddenBeforeDateTime->getTimestamp() > $now) { $isTimedPage = true; } if ($hiddenAfterDateTime !== null) { $isTimedPage = true; } $classes = array(); if ($isTimedPage === true && $node->isHidden() === false) { array_push($classes, 'neos-timedVisibility'); } if ($node->isHidden() === true) { array_push($classes, 'neos-hidden'); } if ($node->isHiddenInIndex() === true) { array_push($classes, 'neos-hiddenInIndex'); } if ($matched) { array_push($classes, 'neos-matched'); } $uriBuilder = $this->controllerContext->getUriBuilder(); $nodeType = $node->getNodeType(); $nodeTypeConfiguration = $nodeType->getFullConfiguration(); if ($node->getNodeType()->isOfType('Neos.Neos:Document')) { $uriForNode = $uriBuilder->reset()->setFormat('html')->setCreateAbsoluteUri(true)->uriFor('show', array('node' => $node), 'Frontend\\Node', 'Neos.Neos'); } else { $uriForNode = '#'; } $label = $node->getLabel(); $nodeTypeLabel = $node->getNodeType()->getLabel(); $treeNode = array('key' => $node->getContextPath(), 'title' => $label, 'fullTitle' => $node->getProperty('title'), 'nodeTypeLabel' => $nodeTypeLabel, 'tooltip' => '', 'href' => $uriForNode, 'isFolder' => $hasChildNodes, 'isLazy' => $hasChildNodes && !$expand, 'nodeType' => $nodeType->getName(), 'isAutoCreated' => $node->isAutoCreated(), 'expand' => $expand, 'addClass' => implode(' ', $classes), 'name' => $node->getName(), 'iconClass' => isset($nodeTypeConfiguration['ui']) && isset($nodeTypeConfiguration['ui']['icon']) ? $nodeTypeConfiguration['ui']['icon'] : '', 'isHidden' => $node->isHidden()); if ($hasChildNodes) { $treeNode['children'] = $children; } return $treeNode; }
/** * Takes care of creating a redirect to properly render the collection the given node is in. * * @param NodeInterface $node * @param string $typoScriptPath * @return string */ protected function redirectToRenderNode(NodeInterface $node, $typoScriptPath) { $q = new FlowQuery(array($node)); $closestContentCollection = $q->closest('[instanceof Neos.Neos:ContentCollection]')->get(0); $closestDocumentNode = $q->closest('[instanceof Neos.Neos:Document]')->get(0); $this->redirect('show', 'Frontend\\Node', 'Neos.Neos', ['node' => $closestDocumentNode, '__nodeContextPath' => $closestContentCollection->getContextPath(), '__affectedNodeContextPath' => $node->getContextPath(), '__typoScriptPath' => $typoScriptPath], 0, 303, 'html'); }
/** * @param NodeInterface $source The node instance * @param string $targetType not used * @param array $subProperties not used * @param PropertyMappingConfigurationInterface $configuration * @return string The node context path */ public function convertFrom($source, $targetType = null, array $subProperties = array(), PropertyMappingConfigurationInterface $configuration = null) { return $source->getContextPath(); }
/** * {@inheritdoc} */ public function createRedirectsForPublishedNode(NodeInterface $node, Workspace $targetWorkspace) { $nodeType = $node->getNodeType(); if ($targetWorkspace->getName() !== 'live' || !$nodeType->isOfType('Neos.Neos:Document')) { return; } $context = $this->contextFactory->create(['workspaceName' => 'live', 'invisibleContentShown' => true, 'dimensions' => $node->getContext()->getDimensions()]); $targetNode = $context->getNodeByIdentifier($node->getIdentifier()); if ($targetNode === null) { // The page has been added return; } $targetNodeUriPath = $this->buildUriPathForNodeContextPath($targetNode->getContextPath()); if ($targetNodeUriPath === null) { throw new Exception('The target URI path of the node could not be resolved', 1451945358); } $hosts = $this->getHostnames($node->getContext()); // The page has been removed if ($node->isRemoved()) { $this->flushRoutingCacheForNode($targetNode); $statusCode = (int) $this->defaultStatusCode['gone']; $this->redirectStorage->addRedirect($targetNodeUriPath, '', $statusCode, $hosts); return; } // compare the "old" node URI to the new one $nodeUriPath = $this->buildUriPathForNodeContextPath($node->getContextPath()); // use the same regexp than the ContentContextBar Ember View $nodeUriPath = preg_replace('/@[A-Za-z0-9;&,\\-_=]+/', '', $nodeUriPath); if ($nodeUriPath === null || $nodeUriPath === $targetNodeUriPath) { // The page node path has not been changed return; } $this->flushRoutingCacheForNode($targetNode); $statusCode = (int) $this->defaultStatusCode['redirect']; $this->redirectStorage->addRedirect($targetNodeUriPath, $nodeUriPath, $statusCode, $hosts); $q = new FlowQuery([$node]); foreach ($q->children('[instanceof Neos.Neos:Document]') as $childrenNode) { $this->createRedirectsForPublishedNode($childrenNode, $targetWorkspace); } }
/** * Collects metadata attributes used to allow editing of the node in the Neos backend. * * @param array $attributes * @param NodeInterface $node * @return array */ protected function addGenericEditingMetadata(array $attributes, NodeInterface $node) { $attributes['typeof'] = 'typo3:' . $node->getNodeType()->getName(); $attributes['about'] = $node->getContextPath(); $attributes['data-node-_identifier'] = $node->getIdentifier(); $attributes['data-node-__workspace-name'] = $node->getWorkspace()->getName(); $attributes['data-node-__label'] = $node->getLabel(); if ($node->getNodeType()->isOfType('Neos.Neos:ContentCollection')) { $attributes['rel'] = 'typo3:content-collection'; } // these properties are needed together with the current NodeType to evaluate Node Type Constraints // TODO: this can probably be greatly cleaned up once we do not use CreateJS or VIE anymore. if ($node->getParent()) { $attributes['data-node-__parent-node-type'] = $node->getParent()->getNodeType()->getName(); } if ($node->isAutoCreated()) { $attributes['data-node-_name'] = $node->getName(); $attributes['data-node-_is-autocreated'] = 'true'; } if ($node->getParent() && $node->getParent()->isAutoCreated()) { $attributes['data-node-_parent-is-autocreated'] = 'true'; // we shall only add these properties if the parent is actually auto-created; as the Node-Type-Switcher in the UI relies on that. $attributes['data-node-__parent-node-name'] = $node->getParent()->getName(); $attributes['data-node-__grandparent-node-type'] = $node->getParent()->getParent()->getNodeType()->getName(); } return $attributes; }
/** * 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. * * @param NodeInterface $node The node where the generated path should lead to * @return string The relative route path, possibly prefixed with a segment for identifying the current content dimension values */ protected function resolveRoutePathForNode(NodeInterface $node) { $workspaceName = $node->getContext()->getWorkspaceName(); $nodeContextPath = $node->getContextPath(); $nodeContextPathSuffix = $workspaceName !== 'live' ? substr($nodeContextPath, strpos($nodeContextPath, '@')) : ''; $currentNodeIsSiteNode = $node->getParentPath() === SiteService::SITES_ROOT_PATH; $dimensionsUriSegment = $this->getUriSegmentForDimensions($node->getContext()->getDimensions(), $currentNodeIsSiteNode); $requestPath = $this->getRequestPathByNode($node); return trim($dimensionsUriSegment . $requestPath, '/') . $nodeContextPathSuffix; }
/** * * * @param NodeInterface $movedNode * @param NodeInterface $referenceNode * @param integer $moveOperation */ public function beforeNodeMove(NodeInterface $movedNode, NodeInterface $referenceNode, $moveOperation) { if (!$this->eventEmittingService->isEnabled()) { return; } $this->currentlyMoving += 1; /* @var $nodeEvent NodeEvent */ $nodeEvent = $this->eventEmittingService->emit(self::NODE_MOVE, array('referenceNode' => $referenceNode->getContextPath(), 'moveOperation' => $moveOperation), NodeEvent::class); $nodeEvent->setNode($movedNode); $this->eventEmittingService->pushContext(); }
/** * Set the "context node" this operation was working on. * * @param NodeInterface $node * @return void */ public function setNode(NodeInterface $node) { $this->nodeIdentifier = $node->getIdentifier(); $this->workspaceName = $node->getContext()->getWorkspaceName(); $this->dimension = $node->getContext()->getDimensions(); $context = $node->getContext(); if ($context instanceof ContentContext && $context->getCurrentSite() !== null) { $siteIdentifier = $this->persistenceManager->getIdentifierByObject($context->getCurrentSite()); } else { $siteIdentifier = null; } $this->data = Arrays::arrayMergeRecursiveOverrule($this->data, array('nodeContextPath' => $node->getContextPath(), 'nodeLabel' => $node->getLabel(), 'nodeType' => $node->getNodeType()->getName(), 'site' => $siteIdentifier)); $node = self::getClosestAggregateNode($node); if ($node !== null) { $this->documentNodeIdentifier = $node->getIdentifier(); $this->data = Arrays::arrayMergeRecursiveOverrule($this->data, array('documentNodeContextPath' => $node->getContextPath(), 'documentNodeLabel' => $node->getLabel(), 'documentNodeType' => $node->getNodeType()->getName())); } }
/** * This method generates the Uri through the joinPoint with * temporary overriding the used node * * @param ActionRequest $request * @param JoinPointInterface $joinPoint The current join point * @param NodeInterface $node * @return string $uri */ public function generateUriForNode(ActionRequest $request, JoinPointInterface $joinPoint, NodeInterface $node) { // store original node path to restore it after generating the uri $originalNodePath = $request->getMainRequest()->getArgument('node'); // generate the uri for the given node $request->getMainRequest()->setArgument('node', $node->getContextPath()); $result = $joinPoint->getAdviceChain()->proceed($joinPoint); // restore the original node path $request->getMainRequest()->setArgument('node', $originalNodePath); return $result; }