/** * Shows the specified node and takes visibility and access restrictions into * account. * * @param NodeInterface $node * @return string View output for the specified node * @Flow\SkipCsrfProtection We need to skip CSRF protection here because this action could be called with unsafe requests from widgets or plugins that are rendered on the node - For those the CSRF token is validated on the sub-request, so it is safe to be skipped here * @Flow\IgnoreValidation("node") * @throws NodeNotFoundException */ public function showAction(NodeInterface $node = null) { if ($node === null) { throw new NodeNotFoundException('The requested node does not exist or isn\'t accessible to the current user', 1430218623); } $inBackend = $node->getContext()->isInBackend(); if ($node->getNodeType()->isOfType('Neos.Neos:Shortcut') && !$inBackend) { $this->handleShortcutNode($node); } $this->view->assign('value', $node); if ($inBackend) { $this->overrideViewVariablesFromInternalArguments(); /** @var UserInterfaceMode $renderingMode */ $renderingMode = $node->getContext()->getCurrentRenderingMode(); $this->response->setHeader('Cache-Control', 'no-cache'); if ($renderingMode !== null) { // Deprecated TypoScript context variable from version 2.0. $this->view->assign('editPreviewMode', $renderingMode->getTypoScriptPath()); } if (!$this->view->canRenderWithNodeAndPath()) { $this->view->setTypoScriptPath('rawContent'); } } if ($this->session->isStarted() && $inBackend) { $this->session->putData('lastVisitedNode', $node->getContextPath()); } }
/** * Resolves a shortcut node to the target. The return value can be * * * a NodeInterface instance if the target is a node or a node:// URI * * a string (in case the target is a plain text URI or an asset:// URI) * * NULL in case the shortcut cannot be resolved * * @param NodeInterface $node * @return NodeInterface|string|NULL */ public function resolveShortcutTarget(NodeInterface $node) { $infiniteLoopPrevention = 0; while ($node->getNodeType()->isOfType('Neos.Neos:Shortcut') && $infiniteLoopPrevention < 50) { $infiniteLoopPrevention++; switch ($node->getProperty('targetMode')) { case 'selectedTarget': $target = $node->getProperty('target'); if ($this->linkingService->hasSupportedScheme($target)) { $targetObject = $this->linkingService->convertUriToObject($target, $node); if ($targetObject instanceof NodeInterface) { $node = $targetObject; } elseif ($targetObject instanceof AssetInterface) { return $this->linkingService->resolveAssetUri($target); } } else { return $target; } break; case 'parentNode': $node = $node->getParent(); break; case 'firstChildNode': default: $childNodes = $node->getChildNodes('Neos.Neos:Document'); if ($childNodes !== array()) { $node = reset($childNodes); } else { return null; } } } return $node; }
/** * Schedules flushing of the routing cache entries for the given $node * Note that child nodes are flushed automatically because they are tagged with all parents. * * @param NodeInterface $node The node which has changed in some way * @return void */ public function registerNodeChange(NodeInterface $node) { if (in_array($node->getIdentifier(), $this->tagsToFlush)) { return; } if (!$node->getNodeType()->isOfType('Neos.Neos:Document')) { return; } $this->tagsToFlush[] = $node->getIdentifier(); }
/** * @param NodeInterface $contextNode The node for which the preceding node should be found * @return NodeInterface The preceding node of $contextNode or NULL */ protected function getPrevForNode($contextNode) { $nodesInContext = $contextNode->getParent()->getChildNodes(); for ($i = 0; $i < count($nodesInContext) - 1; $i++) { if ($nodesInContext[$i + 1] === $contextNode) { return $nodesInContext[$i]; } } return null; }
public function setUp() { $this->siteNode = $this->createMock(NodeInterface::class); $this->firstLevelNode = $this->createMock(NodeInterface::class); $this->secondLevelNode = $this->createMock(NodeInterface::class); $this->siteNode->expects($this->any())->method('getPath')->will($this->returnValue('/site')); $this->siteNode->expects($this->any())->method('getChildNodes')->will($this->returnValue(array($this->firstLevelNode))); $this->mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $this->firstLevelNode->expects($this->any())->method('getParent')->will($this->returnValue($this->siteNode)); $this->firstLevelNode->expects($this->any())->method('getPath')->will($this->returnValue('/site/first')); $this->secondLevelNode->expects($this->any())->method('getParent')->will($this->returnValue($this->siteNode)); $this->secondLevelNode->expects($this->any())->method('getPath')->will($this->returnValue('/site/first/second')); }
/** * @param NodeInterface $contextNode The node for which the preceding node should be found * @return NodeInterface The preceding nodes of $contextNode or NULL */ protected function getPrevForNode(NodeInterface $contextNode) { $nodesInContext = $contextNode->getParent()->getChildNodes(); $count = count($nodesInContext) - 1; for ($i = $count; $i > 0; $i--) { if ($nodesInContext[$i] === $contextNode) { unset($nodesInContext[$i]); return array_values($nodesInContext); } else { unset($nodesInContext[$i]); } } return null; }
/** * Generates a URI path segment for a given node taking it's language dimension into account * * @param NodeInterface $node Optional node to determine language dimension * @param string $text Optional text * @return string */ public function generateUriPathSegment(NodeInterface $node = null, $text = null) { if ($node) { $text = $text ?: $node->getLabel() ?: $node->getName(); $dimensions = $node->getContext()->getDimensions(); if (array_key_exists('language', $dimensions) && $dimensions['language'] !== array()) { $locale = new Locale($dimensions['language'][0]); $language = $locale->getLanguage(); } } elseif (strlen($text) === 0) { throw new Exception('Given text was empty.', 1457591815); } $text = $this->transliterationService->transliterate($text, isset($language) ? $language : null); return Transliterator::urlize($text); }
/** * Search all properties for given $term * * TODO: Implement a better search when Flow offer the possibility * * @param string|array $term search term * @param array $searchNodeTypes * @param Context $context * @param NodeInterface $startingPoint * @return array <\Neos\ContentRepository\Domain\Model\NodeInterface> */ public function findByProperties($term, array $searchNodeTypes, Context $context, NodeInterface $startingPoint = null) { if (empty($term)) { throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285); } $searchResult = array(); $nodeTypeFilter = implode(',', $searchNodeTypes); $nodeDataRecords = $this->nodeDataRepository->findByProperties($term, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $startingPoint ? $startingPoint->getPath() : null); foreach ($nodeDataRecords as $nodeData) { $node = $this->nodeFactory->createFromNodeData($nodeData, $context); if ($node !== null) { $searchResult[$node->getPath()] = $node; } } return $searchResult; }
/** * Wrap the $content identified by $node with the needed markup for the backend. * * @param NodeInterface $node * @param string $property * @param string $content * @return string */ public function wrapContentProperty(NodeInterface $node, $property, $content) { /** @var $contentContext ContentContext */ $contentContext = $node->getContext(); if ($contentContext->getWorkspaceName() === 'live' || !$this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess')) { return $content; } if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) { return $content; } $attributes = array(); $attributes['class'] = 'neos-inline-editable'; $attributes['property'] = 'typo3:' . $property; $attributes['data-neos-node-type'] = $node->getNodeType()->getName(); return $this->htmlAugmenter->addAttributes($content, $attributes, 'span'); }
/** * @param NodeInterface $node A node * @return array of document nodes */ public function render(NodeInterface $node) { $documentNodes = []; $flowQuery = new FlowQuery(array($node)); $nodes = array_reverse($flowQuery->parents('[instanceof Neos.Neos:Document]')->get()); /** @var NodeInterface $node */ foreach ($nodes as $documentNode) { $documentNodes[] = $documentNode; } if ($node->getNodeType()->isOfType('Neos.Neos:Document')) { $documentNodes[] = $node; } $this->templateVariableContainer->add('documentNodes', $documentNodes); $content = $this->renderChildren(); $this->templateVariableContainer->remove('documentNodes'); return $content; }
/** * @test */ public function inheritanceBasedConstraintsWork() { $testingNodeTypeWithSubnodes = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeTypeWithSubnodes'); $testingNodeTypeThatInheritsFromDocumentType = $this->nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Page'); $nodeWithChildNode = $this->rootNode->createNode('node-with-child-node', $testingNodeTypeWithSubnodes); $nodeWithChildNode->createNode('page', $testingNodeTypeThatInheritsFromDocumentType); $this->assertCount(2, $nodeWithChildNode->getChildNodes()); }
/** * Removes unused ImageVariants after a Node property changes to a different ImageVariant. * This is triggered via the nodePropertyChanged event. * * Note: This method it triggered by the "nodePropertyChanged" signal, @see \Neos\ContentRepository\Domain\Model\Node::emitNodePropertyChanged() * * @param NodeInterface $node the affected node * @param string $propertyName name of the property that has been changed/added * @param mixed $oldValue the property value before it was changed or NULL if the property is new * @param mixed $value the new property value * @return void */ public function removeUnusedImageVariant(NodeInterface $node, $propertyName, $oldValue, $value) { if ($oldValue === $value || !$oldValue instanceof ImageVariant) { return; } $identifier = $this->persistenceManager->getIdentifierByObject($oldValue); $results = $this->nodeDataRepository->findNodesByRelatedEntities(array(ImageVariant::class => [$identifier])); // This case shouldn't happen as the query will usually find at least the node that triggered this call, still if there is no relation we can remove the ImageVariant. if ($results === []) { $this->assetRepository->remove($oldValue); return; } // If the result contains exactly the node that got a new ImageVariant assigned then we are safe to remove the asset here. if ($results === [$node->getNodeData()]) { $this->assetRepository->remove($oldValue); } }
public function setUp() { parent::setUp(); $this->contentElementEditableService = new ContentElementEditableService(); $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock(); $this->inject($this->contentElementEditableService, 'privilegeManager', $this->mockPrivilegeManager); $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock(); $this->inject($this->contentElementEditableService, 'nodeAuthorizationService', $this->mockNodeAuthorizationService); $this->mockHtmlAugmenter = $this->getMockBuilder(HtmlAugmenter::class)->getMock(); $this->inject($this->contentElementEditableService, 'htmlAugmenter', $this->mockHtmlAugmenter); $this->mockTsRuntime = $this->getMockBuilder(\Neos\Fusion\Core\Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockContentContext = $this->getMockBuilder(\Neos\Neos\Domain\Service\ContentContext::class)->disableOriginalConstructor()->getMock(); $this->mockNode = $this->getMockBuilder(\Neos\ContentRepository\Domain\Model\NodeInterface::class)->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext)); $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], []))); $this->mockTsContext = array('node' => $this->mockNode); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext)); }
/** * @test */ public function moveAfterInPersonalWorkspaceDoesNotAffectLiveWorkspace() { // move "teaser" after "main/dummy42" $teaserTestWorkspace = $this->nodeInTestWorkspace->getNode('teaser'); $teaserTestWorkspace->moveAfter($this->nodeInTestWorkspace->getNode('main/dummy42')); $this->assertNull($this->nodeInTestWorkspace->getNode('teaser/dummy42a'), 'moving not successful (1)'); $this->assertNotNull($this->nodeInTestWorkspace->getNode('main/teaser/dummy42a'), 'moving not successful (2)'); $this->assertNotNull($this->node->getNode('teaser'), 'moving shined through into live workspace (1)'); $this->assertNotNull($this->node->getNode('teaser/dummy42a'), 'moving shined through into live workspace (2)'); $this->assertNull($this->node->getNode('main/teaser/dummy42a'), 'moving shined through into live workspace (3)'); }
/** * Set up the following node structure: * * /headline (Neos.ContentRepository.Testing:Headline) * - live workspace * - title: Hello World * - personal workspace * - title: Hello World * - subtitle: Brave new world * /headline with language=de_DE * - personal workspace * - title: Hallo Welt * @return void */ protected function setupNodeWithShadowNodeInPersonalWorkspace() { $nodeTypeManager = $this->objectManager->get(NodeTypeManager::class); $headlineNode = $this->rootNodeInLiveWorkspace->createNode('headline', $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:Headline')); $headlineNode->setProperty('title', 'Hello World'); $headlineNodeInPersonalWorkspace = $this->rootNodeInPersonalWorkspace->getNode('headline'); $headlineNodeInPersonalWorkspace->setProperty('subtitle', 'Brave new world'); $germanContext = $this->contextFactory->create(array('workspaceName' => $this->currentTestWorkspaceName, 'dimensions' => array('language' => array('de_DE', 'mul_ZZ')))); $headlineInGerman = $germanContext->getNode('/headline'); $headlineInGerman->setProperty('title', 'Hallo Welt'); $this->flushNodeChanges(); }
public function setUp() { $this->convertUrisImplementation = $this->getAccessibleMock(ConvertUrisImplementation::class, array('tsValue'), array(), '', false); $this->mockWorkspace = $this->getMockBuilder(Workspace::class)->disableOriginalConstructor()->getMock(); $this->mockContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $this->mockContext->expects($this->any())->method('getWorkspace')->will($this->returnValue($this->mockWorkspace)); $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContext)); $this->mockHttpUri = $this->getMockBuilder(Uri::class)->disableOriginalConstructor()->getMock(); $this->mockHttpUri->expects($this->any())->method('getHost')->will($this->returnValue('localhost')); $this->mockHttpRequest = $this->getMockBuilder(Request::class)->disableOriginalConstructor()->getMock(); $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockHttpUri)); $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock(); $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest)); $this->mockControllerContext = $this->getMockBuilder(ControllerContext::class)->disableOriginalConstructor()->getMock(); $this->mockControllerContext->expects($this->any())->method('getRequest')->will($this->returnValue($this->mockActionRequest)); $this->mockLinkingService = $this->createMock(LinkingService::class); $this->convertUrisImplementation->_set('linkingService', $this->mockLinkingService); $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockTsRuntime->expects($this->any())->method('getControllerContext')->will($this->returnValue($this->mockControllerContext)); $this->convertUrisImplementation->_set('tsRuntime', $this->mockTsRuntime); }
/** * Resolves the given $nodePathOrIdentifier and returns its absolute path and or a boolean if the result directly matches the currently selected node * * @param string $nodePathOrIdentifier identifier or absolute path for the node to resolve * @return bool|string TRUE if the node matches the selected node, FALSE if the corresponding node does not exist. Otherwise the resolved absolute path with trailing slash */ protected function resolveNodePath($nodePathOrIdentifier) { if ($this->node === null) { return true; } if (preg_match(UuidValidator::PATTERN_MATCH_UUID, $nodePathOrIdentifier) !== 1) { return rtrim($nodePathOrIdentifier, '/') . '/'; } if ($this->node->getIdentifier() === $nodePathOrIdentifier) { return true; } $node = $this->getNodeByIdentifier($nodePathOrIdentifier); if ($node === null) { return false; } return $node->getPath() . '/'; }
/** * Register a node change for a later cache flush. This method is triggered by a signal sent via ContentRepository's Node * model or the Neos Publishing Service. * * @param NodeInterface $node The node which has changed in some way * @return void */ public function registerNodeChange(NodeInterface $node) { $this->tagsToFlush[ContentCache::TAG_EVERYTHING] = 'which were tagged with "Everything".'; $nodeTypesToFlush = $this->getAllImplementedNodeTypes($node->getNodeType()); foreach ($nodeTypesToFlush as $nodeType) { $nodeTypeName = $nodeType->getName(); $this->tagsToFlush['NodeType_' . $nodeTypeName] = sprintf('which were tagged with "NodeType_%s" because node "%s" has changed and was of type "%s".', $nodeTypeName, $node->getPath(), $node->getNodeType()->getName()); } $this->tagsToFlush['Node_' . $node->getIdentifier()] = sprintf('which were tagged with "Node_%s" because node "%s" has changed.', $node->getIdentifier(), $node->getPath()); $originalNode = $node; while ($node->getDepth() > 1) { $node = $node->getParent(); // Workaround for issue #56566 in Neos.ContentRepository if ($node === null) { break; } $tagName = 'DescendantOf_' . $node->getIdentifier(); $this->tagsToFlush[$tagName] = sprintf('which were tagged with "%s" because node "%s" has changed.', $tagName, $originalNode->getPath()); } }
/** * Returns the plugin namespace that will be prefixed to plugin parameters in URIs. * By default this is <plugin_class_name> * * @return string */ protected function getPluginNamespace() { if ($this->getArgumentNamespace() !== null) { return $this->getArgumentNamespace(); } if ($this->node instanceof NodeInterface) { $nodeArgumentNamespace = $this->node->getProperty('argumentNamespace'); if ($nodeArgumentNamespace !== null) { return $nodeArgumentNamespace; } $nodeArgumentNamespace = $this->node->getNodeType()->getName(); $nodeArgumentNamespace = str_replace(':', '-', $nodeArgumentNamespace); $nodeArgumentNamespace = str_replace('.', '_', $nodeArgumentNamespace); $nodeArgumentNamespace = strtolower($nodeArgumentNamespace); return $nodeArgumentNamespace; } $argumentNamespace = str_replace(array(':', '.', '\\'), array('_', '_', '_'), $this->getPackage() . '_' . $this->getSubpackage() . '-' . $this->getController()); $argumentNamespace = strtolower($argumentNamespace); return $argumentNamespace; }
/** * Returns the rendered content of this plugin * * @return string The rendered content as a string * @throws StopActionException */ public function evaluate() { $currentContext = $this->tsRuntime->getCurrentContext(); $this->pluginViewNode = $currentContext['node']; /** @var $parentResponse Response */ $parentResponse = $this->tsRuntime->getControllerContext()->getResponse(); $pluginResponse = new Response($parentResponse); $pluginRequest = $this->buildPluginRequest(); if ($pluginRequest->getControllerObjectName() === '') { $message = 'Master View not selected'; if ($this->pluginViewNode->getProperty('plugin')) { $message = 'Plugin View not selected'; } if ($this->pluginViewNode->getProperty('view')) { $message = 'Master View or Plugin View not found'; } return $this->pluginViewNode->getContext()->getWorkspaceName() !== 'live' || $this->objectManager->getContext()->isDevelopment() ? '<p>' . $message . '</p>' : '<!-- ' . $message . '-->'; } $this->dispatcher->dispatch($pluginRequest, $pluginResponse); return $pluginResponse->getContent(); }
/** * @param integer $currentPage * @return void * @throws PageNotFoundException */ public function indexAction($currentPage = 1) { $this->currentPage = (int) $currentPage; if ($this->currentPage < 1) { $this->currentPage = 1; } elseif ($this->currentPage > $this->numberOfPages) { throw new PageNotFoundException(); } $itemsPerPage = (int) $this->configuration['itemsPerPage']; if ($this->maximumNumberOfNodes > 0 && $this->maximumNumberOfNodes < $itemsPerPage) { $itemsPerPage = $this->maximumNumberOfNodes; } $offset = $this->currentPage > 1 ? (int) ($itemsPerPage * ($this->currentPage - 1)) : null; if ($this->parentNode === null) { $nodes = array_slice($this->nodes, $offset, $itemsPerPage); } else { $nodes = $this->parentNode->getChildNodes($this->nodeTypeFilter, $itemsPerPage, $offset); } $this->view->assign('contentArguments', array($this->widgetConfiguration['as'] => $nodes)); $this->view->assign('configuration', $this->configuration); $this->view->assign('pagination', $this->buildPagination()); }
/** * Check if the given node is already a collection, find collection by nodePath otherwise, throw exception * if no content collection could be found * * @param NodeInterface $node * @param string $nodePath * @return NodeInterface * @throws Exception */ public function nearestContentCollection(NodeInterface $node, $nodePath) { $contentCollectionType = 'Neos.Neos:ContentCollection'; if ($node->getNodeType()->isOfType($contentCollectionType)) { return $node; } else { if ((string) $nodePath === '') { throw new Exception(sprintf('No content collection of type %s could be found in the current node and no node path was provided. You might want to configure the nodePath property with a relative path to the content collection.', $contentCollectionType), 1409300545); } $subNode = $node->getNode($nodePath); if ($subNode !== null && $subNode->getNodeType()->isOfType($contentCollectionType)) { return $subNode; } else { throw new Exception(sprintf('No content collection of type %s could be found in the current node (%s) or at the path "%s". You might want to adjust your node type configuration and create the missing child node through the "flow node:repair --node-type %s" command.', $contentCollectionType, $node->getPath(), $nodePath, (string) $node->getNodeType()), 1389352984); } } }
public function setUp() { parent::setUp(); $this->editableViewHelper = $this->getAccessibleMock(EditableViewHelper::class, array('renderChildren')); $this->mockPrivilegeManager = $this->getMockBuilder(PrivilegeManagerInterface::class)->getMock(); $this->inject($this->editableViewHelper, 'privilegeManager', $this->mockPrivilegeManager); $this->mockNodeAuthorizationService = $this->getMockBuilder(AuthorizationService::class)->getMock(); $this->inject($this->editableViewHelper, 'nodeAuthorizationService', $this->mockNodeAuthorizationService); $this->mockContentElementEditableService = $this->getMockBuilder(ContentElementEditableService::class)->getMock(); $this->inject($this->editableViewHelper, 'contentElementEditableService', $this->mockContentElementEditableService); $this->mockTemplateImplementation = $this->getMockBuilder(TemplateImplementation::class)->disableOriginalConstructor()->getMock(); $this->mockTsRuntime = $this->getMockBuilder(Runtime::class)->disableOriginalConstructor()->getMock(); $this->mockContentContext = $this->getMockBuilder(ContentContext::class)->disableOriginalConstructor()->getMock(); $this->mockNode = $this->getMockBuilder(NodeInterface::class)->getMock(); $this->mockNode->expects($this->any())->method('getContext')->will($this->returnValue($this->mockContentContext)); $this->mockNode->expects($this->any())->method('getNodeType')->will($this->returnValue(new NodeType('Acme.Test:Headline', [], []))); $this->mockTsContext = array('node' => $this->mockNode); $this->mockTsRuntime->expects($this->any())->method('getCurrentContext')->will($this->returnValue($this->mockTsContext)); $this->mockTemplateImplementation->expects($this->any())->method('getTsRuntime')->will($this->returnValue($this->mockTsRuntime)); $this->mockView = $this->getAccessibleMock(FluidView::class, array(), array(), '', false); $this->mockView->expects($this->any())->method('getTypoScriptObject')->will($this->returnValue($this->mockTemplateImplementation)); $this->editableViewHelper->initializeArguments(); }
/** * Publishes the given node to the specified target workspace. If no workspace is specified, the base workspace * is assumed. * * If the given node is a Document or has ContentCollection child nodes, these nodes are published as well. * * @param NodeInterface $node * @param Workspace $targetWorkspace If not set the base workspace is assumed to be the publishing target * @return void * @api */ public function publishNode(NodeInterface $node, Workspace $targetWorkspace = null) { if ($targetWorkspace === null) { $targetWorkspace = $node->getWorkspace()->getBaseWorkspace(); } if (!$targetWorkspace instanceof Workspace) { return; } $nodes = array($node); $nodeType = $node->getNodeType(); if ($nodeType->isOfType('Neos.Neos:Document') || $nodeType->hasConfiguration('childNodes')) { foreach ($node->getChildNodes('Neos.Neos:ContentCollection') as $contentCollectionNode) { array_push($nodes, $contentCollectionNode); } } $sourceWorkspace = $node->getWorkspace(); $sourceWorkspace->publishNodes($nodes, $targetWorkspace); $this->emitNodePublished($node, $targetWorkspace); }
/** * Returns an array with the data needed by for example the Hallo and Aloha * link plugins to represent the passed Node instance. * * @param NodeInterface $node * @return array */ protected function processNodeForEditorPlugins(NodeInterface $node) { return array('id' => $node->getPath(), 'name' => $node->getLabel(), 'url' => $this->uriBuilder->uriFor('show', array('node' => $node), 'Frontend\\Node', 'Neos.Neos'), 'type' => 'neos/internal-link'); }
/** * @param NodeInterface $mockNode * @param array $nodeContextProperties * @return FlowQuery */ protected function buildFlowQueryWithNodeInContext($mockNode, $nodeContextProperties) { $mockNodeContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock(); $mockNodeContext->expects($this->any())->method('getProperties')->will($this->returnValue($nodeContextProperties)); $mockNode->expects($this->any())->method('getContext')->will($this->returnValue($mockNodeContext)); $mockFlowQuery = $this->getMockBuilder(FlowQuery::class)->disableOriginalConstructor()->getMock(); $mockFlowQuery->expects($this->any())->method('getContext')->will($this->returnValue(array($mockNode))); return $mockFlowQuery; }
/** * Filter a node by the current context. * Will either return the node or NULL if it is not permitted in current context. * * @param NodeInterface $node * @param Context $context * @return NodeInterface|NULL */ protected function filterNodeByContext(NodeInterface $node, Context $context) { $this->securityContext->withoutAuthorizationChecks(function () use(&$node, $context) { if (!$context->isRemovedContentShown() && $node->isRemoved()) { $node = null; return; } if (!$context->isInvisibleContentShown() && !$node->isVisible()) { $node = null; return; } if (!$context->isInaccessibleContentShown() && !$node->isAccessible()) { $node = null; } }); return $node; }
/** * Node Level relative to site root node. * 0 = Site root node * * @param NodeInterface $node * @return integer */ protected function getNodeLevelInSite(NodeInterface $node) { $siteNode = $this->currentNode->getContext()->getCurrentSiteNode(); return $node->getDepth() - $siteNode->getDepth(); }
/** * @param array $nextNodes the remaining nodes * @param NodeInterface $until * @return array */ protected function getNodesUntil($nextNodes, NodeInterface $until) { $count = count($nextNodes) - 1; for ($i = $count; $i >= 0; $i--) { if ($nextNodes[$i]->getPath() === $until->getPath()) { unset($nextNodes[$i]); return array_values($nextNodes); } else { unset($nextNodes[$i]); } } return array_values($nextNodes); }
/** * @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; }