persistEntities() публичный Метод

Persists all entities managed by the repository and all cascading dependencies
public persistEntities ( ) : void
Результат void
 /**
  * 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="Neos.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');
 }
 /**
  * Testcase for bug #34291 (ContentRepository 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);
 }
Пример #3
0
 /**
  * Moves this node into the given node
  *
  * @param NodeInterface $referenceNode
  * @param string $newName
  * @throws NodeConstraintException
  * @throws NodeException
  * @throws NodeExistsException
  * @api
  */
 public function moveInto(NodeInterface $referenceNode, $newName = null)
 {
     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);
     }
     $name = $newName !== null ? $newName : $this->getName();
     $this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
     $this->setPath(NodePaths::addNodePathSegment($referenceNode->getPath(), $name));
     $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);
 }