Returns the current workspace.
public getWorkspace ( boolean $createWorkspaceIfNecessary = true ) : |
||
$createWorkspaceIfNecessary | boolean | DEPRECATED: If enabled, creates a workspace with the configured name if it doesn't exist already. This option is DEPRECATED, create workspace explicitly instead. |
return | The workspace or NULL |
/** * Tests addPathConstraintToQueryBuilder, see https://jira.neos.io/browse/NEOS-1849 * * @test */ public function findByPathWithoutReduceLimitsToRootNodeCorrectly() { $this->setUpNodes(); $workspace = $this->context->getWorkspace(); $foundNodes = $this->nodeDataRepository->findByPathWithoutReduce('/', $workspace, false, true); $this->assertCount(7, $foundNodes); }
/** * @test */ public function sortByDateTimeDescending() { $nodesToSort = [$this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), array())]; $correctOrder = [$this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addd', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115addf', $this->context->getWorkspace(true), array()), $this->nodeDataRepository->findOneByIdentifier('c381f64d-4269-429a-9c21-6d846115adde', $this->context->getWorkspace(true), array())]; $flowQuery = new \Neos\Eel\FlowQuery\FlowQuery($nodesToSort); $operation = new SortOperation(); $operation->evaluate($flowQuery, ['_lastPublicationDateTime', 'DESC']); $this->assertEquals($correctOrder, $flowQuery->getContext()); }
/** * @test */ public function nodeFactoryCachesCreatedNodesBasedOnIdentifierAndDimensions() { /** @var NodeFactory $nodeFactory */ $nodeFactory = $this->objectManager->get(NodeFactory::class); $nodeDataA = new NodeData('/', $this->context->getWorkspace(), '30e893c1-caef-0ca5-b53d-e5699bb8e506', ['test' => [1]]); $variantNodeA1 = $nodeFactory->createFromNodeData($nodeDataA, $this->context); $variantNodeA2 = $nodeFactory->createFromNodeData($nodeDataA, $this->context); $nodeDataB = new NodeData('/', $this->context->getWorkspace(), '30e893c1-caef-0ca5-b53d-e5699bb8e506', ['test' => [2]]); $variantNodeB = $nodeFactory->createFromNodeData($nodeDataB, $this->context); $this->assertSame($variantNodeA1, $variantNodeA2); $this->assertSame($variantNodeA1, $variantNodeB); }
/** * 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; }
/** * Finds a single node by its parent and (optionally) by its node type * * @param string $parentPath Absolute path of the parent node * @param string $nodeTypeFilter Filter the node type of the nodes, allows complex expressions (e.g. "Neos.Neos:Page", "!Neos.Neos:Page,Neos.Neos:Text" or NULL) * @param Context $context The containing context * @return NodeData The node found or NULL */ public function findFirstByParentAndNodeTypeInContext($parentPath, $nodeTypeFilter, Context $context) { $firstNode = $this->findFirstByParentAndNodeType($parentPath, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $context->isRemovedContentShown() ? null : false); if ($firstNode !== null) { $firstNode = $this->nodeFactory->createFromNodeData($firstNode, $context); } return $firstNode; }
/** * Given a context a new node is returned that is like this node, but * lives in the new context. * * @param Context $context * @return NodeInterface */ public function createVariantForContext($context) { $autoCreatedChildNodes = []; $nodeType = $this->getNodeType(); foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) { $childNode = $this->getNode($childNodeName); if ($childNode !== null) { $autoCreatedChildNodes[$childNodeName] = $childNode; } } $nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues()); $nodeData->similarize($this->nodeData); if ($this->context !== $context) { $node = $this->nodeFactory->createFromNodeData($nodeData, $context); } else { $this->setNodeData($nodeData); $node = $this; } $this->context->getFirstLevelNodeCache()->flush(); $this->emitNodeAdded($node); /** * @var $autoCreatedChildNode NodeInterface */ foreach ($autoCreatedChildNodes as $autoCreatedChildNode) { $autoCreatedChildNode->createVariantForContext($context); } return $node; }