本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::findByPathWithoutReduce方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeDataRepository::findByPathWithoutReduce方法的具体用法?PHP NodeDataRepository::findByPathWithoutReduce怎么用?PHP NodeDataRepository::findByPathWithoutReduce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository
的用法示例。
在下文中一共展示了NodeDataRepository::findByPathWithoutReduce方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByPathWithoutReduceLimitsToRootNodeCorrectly
/**
* 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);
}
示例2: setPath
/**
* Sets the absolute path of this node.
*
* This method is only for internal use by the content repository or node methods. Changing
* the path of a node manually may lead to unexpected behavior.
*
* To achieve a correct behavior when changing the path (moving the node) in a workspace, a shadow node data that will
* hide the node data in the base workspace will be created. Thus queries do not need to worry about moved nodes.
* Through a movedTo reference the shadow node data will be removed when publishing the moved node.
*
* @param string $path
* @param boolean $checkForExistence Checks for existence at target path, internally used for recursions and shadow nodes.
* @throws NodeException
* @internal This method is purely internal and Node objects can call this on other Node objects
*/
public function setPath($path, $checkForExistence = true)
{
$originalPath = $this->nodeData->getPath();
if ($originalPath === $path) {
return;
}
if ($checkForExistence) {
$existingNodeDataArray = $this->nodeDataRepository->findByPathWithoutReduce($path, $this->context->getWorkspace());
/** @var NodeData $existingNodeData */
foreach ($existingNodeDataArray as $existingNodeData) {
if ($existingNodeData->getIdentifier() !== $this->getIdentifier()) {
throw new NodeException(sprintf('Can not rename the node "%s" as a node already exists on path "%s"', $this->getPath(), $path), 1414436551);
}
}
}
$changedNodePathsCollection = array();
if ($this->getNodeType()->isAggregate()) {
$nodeDataVariantsAndChildren = $this->nodeDataRepository->findByPathWithoutReduce($originalPath, $this->context->getWorkspace(), true, true);
/** @var NodeData $nodeData */
foreach ($nodeDataVariantsAndChildren as $nodeData) {
// $nodeDataVariants at this point also contains *our own NodeData reference* ($this->nodeData), as we find all NodeData objects
// (across all dimensions) with the same path.
//
// We need to ensure that our own Node object's nodeData reference ($this->nodeData) is also updated correctly if a new NodeData object
// is returned; as we rely on the fact that $this->getPath() will return the new node path in all circumstances.
//
// However, $this->createNodeForVariant() only returns $this if the Context object is the same as $this->context; which is not
// the case if $this->context contains dimension fallbacks such as "Language: EN, DE".
//
// The "if" statement below is actually a workaround to ensure that if the NodeData object is our own one, we update *ourselves* correctly,
// and thus return the correct (new) Node Path when calling $this->getPath() afterwards.
if ($this->nodeData === $nodeData) {
$nodeVariant = $this;
} else {
$nodeVariant = $this->createNodeForVariant($nodeData);
}
if ($nodeVariant !== null) {
$relativePathSegment = NodePaths::getRelativePathBetween($originalPath, $nodeVariant->getPath());
$newNodeVariantPath = NodePaths::addNodePathSegment($path, $relativePathSegment);
$possibleShadowedNodeData = $nodeData->move($newNodeVariantPath, $this->context->getWorkspace());
$nodeVariant->setNodeData($possibleShadowedNodeData);
$changedNodePathsCollection[] = array($nodeVariant, $originalPath, $nodeVariant->getNodeData()->getPath(), !$checkForExistence);
}
}
} else {
/** @var Node $childNode */
foreach ($this->getChildNodes() as $childNode) {
$childNode->setPath(NodePaths::addNodePathSegment($path, $childNode->getName()), false);
}
$possibleShadowedNodeData = $this->nodeData->move($path, $this->context->getWorkspace());
$this->setNodeData($possibleShadowedNodeData);
$changedNodePathsCollection[] = array($this, $originalPath, $this->getNodeData()->getPath(), $checkForExistence);
}
$this->nodeDataRepository->persistEntities();
foreach ($changedNodePathsCollection as $nodePathChangedArguments) {
call_user_func_array(array($this, 'emitNodePathChanged'), $nodePathChangedArguments);
}
}
示例3: setPathInternalForAggregate
/**
* Moves a node and sub nodes to the new path given with special logic for aggregate node types.
*
* @param string $destinationPath the new node path
* @param boolean $recursiveCall is this a recursive call
* @return array of arrays with NodeVariant and old and new path and if this was a recursive call
*/
protected function setPathInternalForAggregate($destinationPath, $recursiveCall)
{
$originalPath = $this->nodeData->getPath();
$nodeDataVariantsAndChildren = $this->nodeDataRepository->findByPathWithoutReduce($originalPath, $this->context->getWorkspace(), true, true);
$changedNodePathsCollection = array_map(function ($nodeData) use($destinationPath, $originalPath, $recursiveCall) {
return $this->moveNodeData($nodeData, $originalPath, $destinationPath, $recursiveCall);
}, $nodeDataVariantsAndChildren);
return array_filter($changedNodePathsCollection);
}
示例4: nodePathAvailableForNode
/**
* Checks if the given node path can be used for the given node.
*
* @param string $nodePath
* @param NodeInterface $node
* @return boolean
*/
public function nodePathAvailableForNode($nodePath, NodeInterface $node)
{
/** @var NodeData $existingNodeData */
$existingNodeDataObjects = $this->nodeDataRepository->findByPathWithoutReduce($nodePath, $node->getWorkspace(), true);
foreach ($existingNodeDataObjects as $existingNodeData) {
if ($existingNodeData->getMovedTo() !== null && $existingNodeData->getMovedTo() === $node->getNodeData()) {
return true;
}
}
return !$this->nodePathExistsInAnyContext($nodePath);
}
示例5: setPath
/**
* Sets the absolute path of this node.
*
* This method is only for internal use by the content repository or node methods. Changing
* the path of a node manually may lead to unexpected behavior.
*
* To achieve a correct behavior when changing the path (moving the node) in a workspace, a shadow node data that will
* hide the node data in the base workspace will be created. Thus queries do not need to worry about moved nodes.
* Through a movedTo reference the shadow node data will be removed when publishing the moved node.
*
* @param string $path
* @param boolean $checkForExistence Checks for existence at target path, internally used for recursions and shadow nodes.
* @throws NodeException
* @internal This method is purely internal and Node objects can call this on other Node objects
*/
public function setPath($path, $checkForExistence = true)
{
$originalPath = $this->nodeData->getPath();
if ($originalPath === $path) {
return;
}
if ($checkForExistence) {
$existingNodeDataArray = $this->nodeDataRepository->findByPathWithoutReduce($path, $this->context->getWorkspace());
/** @var NodeData $existingNodeData */
foreach ($existingNodeDataArray as $existingNodeData) {
if ($existingNodeData->getIdentifier() !== $this->getIdentifier()) {
throw new NodeException(sprintf('Can not rename the node "%s" as a node already exists on path "%s"', $this->getPath(), $path), 1414436551);
}
}
}
$changedNodePathsCollection = array();
if ($this->getNodeType()->isAggregate()) {
$nodeDataVariantsAndChildren = $this->nodeDataRepository->findByPathWithoutReduce($originalPath, $this->context->getWorkspace(), true, true);
/** @var NodeData $nodeData */
foreach ($nodeDataVariantsAndChildren as $nodeData) {
$nodeVariant = $this->createNodeForVariant($nodeData);
if ($nodeVariant !== null) {
$relativePathSegment = NodePaths::getRelativePathBetween($originalPath, $nodeVariant->getPath());
$newNodeVariantPath = NodePaths::addNodePathSegment($path, $relativePathSegment);
$possibleShadowedNodeData = $nodeData->move($newNodeVariantPath, $this->context->getWorkspace());
$nodeVariant->setNodeData($possibleShadowedNodeData);
$changedNodePathsCollection[] = array($nodeVariant, $originalPath, $nodeVariant->getNodeData()->getPath(), !$checkForExistence);
}
}
} else {
/** @var Node $childNode */
foreach ($this->getChildNodes() as $childNode) {
$childNode->setPath(NodePaths::addNodePathSegment($path, $childNode->getName()), false);
}
$possibleShadowedNodeData = $this->nodeData->move($path, $this->context->getWorkspace());
$this->setNodeData($possibleShadowedNodeData);
$changedNodePathsCollection[] = array($this, $originalPath, $this->getNodeData()->getPath(), $checkForExistence);
}
$this->nodeDataRepository->persistEntities();
foreach ($changedNodePathsCollection as $nodePathChangedArguments) {
call_user_func_array(array($this, 'emitNodePathChanged'), $nodePathChangedArguments);
}
}