Beispiel #1
0
 /**
  * Sets the workflow properties on the given document.
  *
  * @param WorkflowStageBehavior $document
  * @param DocumentAccessor $accessor
  * @param string $workflowStage
  * @param string $locale
  * @param string $live
  *
  * @throws \Sulu\Component\DocumentManager\Exception\DocumentManagerException
  */
 private function setWorkflowStage(WorkflowStageBehavior $document, DocumentAccessor $accessor, $workflowStage, $locale, $live)
 {
     $path = $this->documentInspector->getPath($document);
     $document->setWorkflowStage($workflowStage);
     $updatePublished = !$document->getPublished() && $workflowStage === WorkflowStage::PUBLISHED;
     if ($updatePublished) {
         $accessor->set(self::PUBLISHED_FIELD, new \DateTime());
     }
     $defaultNode = $this->defaultSession->getNode($path);
     $this->setWorkflowStageOnNode($defaultNode, $locale, $workflowStage, $updatePublished);
     if ($live) {
         $liveNode = $this->liveSession->getNode($path);
         $this->setWorkflowStageOnNode($liveNode, $locale, $workflowStage, $updatePublished);
     }
 }
Beispiel #2
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;
     }
 }