/** * @param HydrateEvent $event */ public function handleHydrate(HydrateEvent $event) { $document = $event->getDocument(); if (!$document instanceof PathBehavior) { return; } $event->getAccessor()->set('path', $this->documentInspector->getPath($document)); }
/** * 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); } }