本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::setNewIndex方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeDataRepository::setNewIndex方法的具体用法?PHP NodeDataRepository::setNewIndex怎么用?PHP NodeDataRepository::setNewIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository
的用法示例。
在下文中一共展示了NodeDataRepository::setNewIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: moveInto
/**
* Moves this node into the given node
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $referenceNode
* @throws \TYPO3\TYPO3CR\Exception\NodeExistsException
* @throws \TYPO3\TYPO3CR\Exception\NodeException
* @return void
* @api
*/
public function moveInto(NodeInterface $referenceNode)
{
if ($referenceNode === $this || $referenceNode === $this->getParent()) {
return;
}
if ($this->getPath() === '/') {
throw new \TYPO3\TYPO3CR\Exception\NodeException('The root node cannot be moved.', 1346769001);
}
if ($referenceNode !== $this->getParent() && $referenceNode->getNode($this->getName()) !== NULL) {
throw new \TYPO3\TYPO3CR\Exception\NodeExistsException('Node with path "' . $this->getName() . '" already exists.', 1292503470);
}
if (!$this->isNodeDataMatchingContext()) {
$this->materializeNodeData();
}
$parentPath = $referenceNode->getPath();
$this->setPath($parentPath . ($parentPath === '/' ? '' : '/') . $this->getName());
$this->nodeDataRepository->persistEntities();
$this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_LAST);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeUpdated($this);
}
示例2: moveInto
/**
* Moves this node into the given node
*
* @param NodeInterface $referenceNode
* @return void
* @throws NodeExistsException
* @throws NodeException
* @throws NodeConstraintException
* @api
*/
public function moveInto(NodeInterface $referenceNode)
{
if ($referenceNode === $this || $referenceNode === $this->getParent()) {
return;
}
if ($this->getPath() === '/') {
throw new NodeException('The root node cannot be moved.', 1346769001);
}
if ($referenceNode !== $this->getParent() && $referenceNode->getNode($this->getName()) !== null) {
throw new NodeExistsException('Node with path "' . $this->getName() . '" already exists.', 1292503470);
}
if (!$referenceNode->willChildNodeBeAutoCreated($this->getName()) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException('Cannot move ' . $this->__toString() . ' into ' . $referenceNode->__toString(), 1404648124);
}
$this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
$this->setPath(NodePaths::addNodePathSegment($referenceNode->getPath(), $this->getName()));
$this->nodeDataRepository->persistEntities();
$this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_LAST);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitAfterNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
$this->emitNodeUpdated($this);
}
示例3: createSingleNodeData
/**
* Creates, adds and returns a child node of this node, without setting default
* properties or creating subnodes.
*
* @param string $name Name of the new node
* @param \TYPO3\TYPO3CR\Domain\Model\NodeType $nodeType Node type of the new node (optional)
* @param string $identifier The identifier of the node, unique within the workspace, optional(!)
* @param \TYPO3\TYPO3CR\Domain\Model\Workspace $workspace
* @param array $dimensions An array of dimension name to dimension values
* @throws NodeExistsException if a node with this path already exists.
* @throws \InvalidArgumentException if the node name is not accepted.
* @return \TYPO3\TYPO3CR\Domain\Model\NodeData
*/
public function createSingleNodeData($name, NodeType $nodeType = NULL, $identifier = NULL, Workspace $workspace = NULL, array $dimensions = NULL)
{
if (!is_string($name) || preg_match(NodeInterface::MATCH_PATTERN_NAME, $name) !== 1) {
throw new \InvalidArgumentException('Invalid node name "' . $name . '" (a node name must only contain characters, numbers and the "-" sign).', 1292428697);
}
$nodeWorkspace = $workspace ?: $this->workspace;
$newPath = $this->path . ($this->path === '/' ? '' : '/') . $name;
if ($this->nodeDataRepository->findOneByPath($newPath, $nodeWorkspace, $dimensions) !== NULL) {
throw new NodeExistsException(sprintf('Node with path "' . $newPath . '" already exists in workspace %s and given dimensions %s.', $nodeWorkspace->getName(), var_export($dimensions, TRUE)), 1292503471);
}
$newNodeData = new NodeData($newPath, $nodeWorkspace, $identifier, $dimensions);
$this->nodeDataRepository->add($newNodeData);
$this->nodeDataRepository->setNewIndex($newNodeData, NodeDataRepository::POSITION_LAST);
if ($nodeType !== NULL) {
$newNodeData->setNodeType($nodeType);
}
return $newNodeData;
}