/**
  * Handle the reorder operation.
  *
  * @param ReorderEvent $event
  *
  * @throws DocumentManagerException
  */
 public function handleReorder(ReorderEvent $event)
 {
     $document = $event->getDocument();
     $siblingId = $event->getDestId();
     $after = $event->getAfter();
     $node = $this->documentRegistry->getNodeForDocument($document);
     $parentNode = $node->getParent();
     $nodeName = $node->getName();
     $siblingName = $this->resolveSiblingName($siblingId, $parentNode, $node);
     if (true === $after) {
         $siblingName = $this->resolveAfterSiblingName($parentNode, $siblingName);
     }
     $parentNode->orderBefore($nodeName, $siblingName);
 }
Example #2
0
 /**
  * Adjusts the order of the document and its siblings.
  *
  * @param ReorderEvent $event
  */
 public function handleReorder(ReorderEvent $event)
 {
     $node = $event->getNode();
     $document = $event->getDocument();
     if (false == $this->supports($document)) {
         return;
     }
     $propertyName = $this->encoder->systemName(self::FIELD);
     $parent = $node->getParent();
     $count = 0;
     foreach ($parent->getNodes() as $childNode) {
         $childNode->setProperty($propertyName, ($count + 1) * 10, PropertyType::LONG);
         ++$count;
     }
     $this->handleHydrate($event);
 }
Example #3
0
 /**
  * Adjusts the order of the document and its siblings.
  *
  * @param ReorderEvent $event
  */
 public function handleReorder(ReorderEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof OrderBehavior) {
         return;
     }
     $parentDocument = $this->inspector->getParent($document);
     if (null === $parentDocument) {
         return;
     }
     $count = 0;
     foreach ($this->inspector->getChildren($parentDocument) as $childDocument) {
         if (!$childDocument instanceof OrderBehavior) {
             continue;
         }
         $accessor = new DocumentAccessor($childDocument);
         $order = ($count + 1) * 10;
         $accessor->set('suluOrder', $order);
         ++$count;
     }
 }
Example #4
0
 /**
  * Adjusts the order of the document and its siblings.
  *
  * @param ReorderEvent $event
  */
 public function handleReorder(ReorderEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof OrderBehavior) {
         return;
     }
     $parentDocument = $this->documentInspector->getParent($document);
     if (null === $parentDocument) {
         return;
     }
     $count = 1;
     foreach ($this->documentInspector->getChildren($parentDocument) as $childDocument) {
         if (!$childDocument instanceof OrderBehavior) {
             continue;
         }
         $order = $count * 10;
         $childDocument->setSuluOrder($order);
         // TODO move to NodeHelper once integrated in sulu/sulu?
         $childNode = $this->documentInspector->getNode($childDocument);
         $childNode->setProperty($this->propertyEncoder->systemName(static::FIELD), $order);
         ++$count;
     }
 }
 /**
  * If the node for the persisted document is in the registry.
  *
  * @param PersistEvent|ReorderEvent $event
  */
 public function handleNodeFromRegistry($event)
 {
     if ($event->hasNode()) {
         return;
     }
     $document = $event->getDocument();
     if (!$this->documentRegistry->hasDocument($document)) {
         return;
     }
     $node = $this->documentRegistry->getNodeForDocument($document);
     $event->setNode($node);
 }
Example #6
0
 /**
  * Reordering is also not draftable, and therefore also immediately applied to the live session.
  *
  * @param ReorderEvent $event
  */
 public function reorderNodeInPublicWorkspace(ReorderEvent $event)
 {
     $node = $this->getLiveNode($event->getDocument());
     $this->nodeHelper->reorder($node, $event->getDestId());
     // FIXME duplicating logic of OrderSubscriber, maybe move to NodeHelper?
     $count = 1;
     foreach ($node->getParent()->getNodes() as $childNode) {
         $childNode->setProperty($this->propertyEncoder->systemName('order'), $count * 10);
         ++$count;
     }
 }