本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository::persistEntities方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeDataRepository::persistEntities方法的具体用法?PHP NodeDataRepository::persistEntities怎么用?PHP NodeDataRepository::persistEntities使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Repository\NodeDataRepository
的用法示例。
在下文中一共展示了NodeDataRepository::persistEntities方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateSiteAction
/**
* Update a site
*
* @param Site $site A site to update
* @param string $newSiteNodeName A new site node name
* @return void
* @Flow\Validate(argumentName="$site", type="UniqueEntity")
* @Flow\Validate(argumentName="$newSiteNodeName", type="NotEmpty")
* @Flow\Validate(argumentName="$newSiteNodeName", type="StringLength", options={ "minimum"=1, "maximum"=250 })
* @Flow\Validate(argumentName="$newSiteNodeName", type="TYPO3.Neos:NodeName")
*/
public function updateSiteAction(Site $site, $newSiteNodeName)
{
if ($site->getNodeName() !== $newSiteNodeName) {
$oldSiteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $site->getNodeName());
$newSiteNodePath = NodePaths::addNodePathSegment(SiteService::SITES_ROOT_PATH, $newSiteNodeName);
/** @var $workspace Workspace */
foreach ($this->workspaceRepository->findAll() as $workspace) {
$siteNode = $this->nodeDataRepository->findOneByPath($oldSiteNodePath, $workspace);
if ($siteNode !== null) {
$siteNode->setPath($newSiteNodePath);
}
}
$site->setNodeName($newSiteNodeName);
$this->nodeDataRepository->persistEntities();
}
$this->siteRepository->update($site);
$this->addFlashMessage('The site "%s" has been updated.', 'Update', null, array(htmlspecialchars($site->getName())), 1412371798);
$this->unsetLastVisitedNodeAndRedirect('index');
}
示例2: updateSiteAction
/**
* Update a site
*
* @param Site $site A site to update
* @param string $newSiteNodeName A new site node name
* @return void
* @Flow\Validate(argumentName="$site", type="UniqueEntity")
* @Flow\Validate(argumentName="$newSiteNodeName", type="NotEmpty")
* @Flow\Validate(argumentName="$newSiteNodeName", type="StringLength", options={ "minimum"=1, "maximum"=250 })
* @Flow\Validate(argumentName="$newSiteNodeName", type="TYPO3.Neos:NodeName")
*/
public function updateSiteAction(Site $site, $newSiteNodeName)
{
if ($site->getNodeName() !== $newSiteNodeName) {
$oldSiteNodePath = '/sites/' . $site->getNodeName();
$newSiteNodePath = '/sites/' . $newSiteNodeName;
/** @var $workspace Workspace */
foreach ($this->workspaceRepository->findAll() as $workspace) {
$siteNode = $this->nodeDataRepository->findOneByPath($oldSiteNodePath, $workspace);
if ($siteNode !== NULL) {
$siteNode->setPath($newSiteNodePath);
}
}
$site->setNodeName($newSiteNodeName);
$this->nodeDataRepository->persistEntities();
}
$this->siteRepository->update($site);
$this->addFlashMessage('The site "%s" has been updated.', 'Update', NULL, array($site->getName()), 1412371798);
$this->unsetLastVisitedNodeAndRedirect('index');
}
示例3: 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);
}
示例4: renumberingTakesUnpersistedNodeOrderChangesIntoAccount
/**
* Testcase for bug #34291 (TYPO3CR reordering does not take unpersisted
* node order changes into account)
*
* The error can be reproduced in the following way:
*
* - First, create some nodes, and persist.
* - Then, move a node after another one, filling the LAST free sorting index between the nodes. Do NOT persist after that.
* - After that, try to *again* move a node to this spot. In this case, we need to *renumber*
* the node indices, and the system needs to take the before-moved node into account as well.
*
* The bug tested by this testcase led to wrong orderings on the floworg website in
* the documentation part under some circumstances.
*
* @test
*/
public function renumberingTakesUnpersistedNodeOrderChangesIntoAccount()
{
$rootNode = $this->context->getRootNode();
$liveParentNode = $rootNode->createNode('parent-node');
$nodes = [];
$nodes[1] = $liveParentNode->createNode('node001');
$nodes[1]->setIndex(1);
$nodes[2] = $liveParentNode->createNode('node002');
$nodes[2]->setIndex(2);
$nodes[3] = $liveParentNode->createNode('node003');
$nodes[3]->setIndex(4);
$nodes[4] = $liveParentNode->createNode('node004');
$nodes[4]->setIndex(5);
$this->nodeDataRepository->persistEntities();
$nodes[1]->moveAfter($nodes[2]);
$nodes[3]->moveAfter($nodes[2]);
$this->nodeDataRepository->persistEntities();
$actualChildNodes = $liveParentNode->getChildNodes();
$newNodeOrder = [$nodes[2], $nodes[3], $nodes[1], $nodes[4]];
$this->assertSameOrder($newNodeOrder, $actualChildNodes);
}
示例5: 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);
}