public function setUp()
 {
     $this->hydrateEvent = $this->prophesize(HydrateEvent::class);
     $this->persistEvent = $this->prophesize(PersistEvent::class);
     $this->encoder = $this->prophesize(PropertyEncoder::class);
     $this->inspector = $this->prophesize(DocumentInspector::class);
     $this->namespaceRegistry = $this->prophesize(NamespaceRegistry::class);
     $this->extensionManager = $this->prophesize(ExtensionManagerInterface::class);
     $this->extension = $this->prophesize(ExtensionInterface::class);
     $this->node = $this->prophesize(NodeInterface::class);
     $this->documentAccessor = $this->prophesize(DocumentAccessor::class);
     $this->subscriber = new ExtensionSubscriber($this->encoder->reveal(), $this->extensionManager->reveal(), $this->inspector->reveal(), $this->namespaceRegistry->reveal());
     $this->hydrateEvent->getNode()->willReturn($this->node->reveal());
     $this->hydrateEvent->getLocale()->willReturn('de');
     $this->hydrateEvent->getAccessor()->willReturn($this->documentAccessor->reveal());
     $this->persistEvent->getNode()->willReturn($this->node->reveal());
     $this->persistEvent->getLocale()->willReturn('de');
 }
Example #2
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);
     }
 }
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;
     }
 }