public function __construct(SessionManagerInterface $sessionManager, SessionInterface $defaultSession, SessionInterface $liveSession, WebspaceManagerInterface $webspaceManager, PropertyEncoder $propertyEncoder) { $this->sessionManager = $sessionManager; $this->defaultSession = $defaultSession; $this->liveSession = $liveSession; $this->webspaceManager = $webspaceManager; $this->propertyName = $propertyEncoder->systemName(OrderSubscriber::FIELD); }
/** * 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; } }
/** * 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; } }