src/Sulu/Component/Content/Document/Subscriber/WorkflowStageSubscriber.php
private function setWorkflowStage(
        WorkflowStageBehavior $document,
        DocumentAccessor $accessor,
        $workflowStage,
        $locale,
        $live
    ) {
        $path = $this->documentInspector->getPath($document);
        $document->setWorkflowStage($workflowStage);

        $publishDate = $document->getPublished();

        if (!$publishDate && WorkflowStage::PUBLISHED === $workflowStage) {
            $publishDate = new \DateTime();
            $accessor->set(self::PUBLISHED_FIELD, $publishDate);
        }

        $defaultNode = $this->defaultSession->getNode($path);
        $this->setWorkflowStageOnNode($defaultNode, $locale, $workflowStage, $publishDate);

        if ($live) {
            $liveNode = $this->liveSession->getNode($path);
            $this->setWorkflowStageOnNode($liveNode, $locale, $workflowStage, $publishDate);
        }
    }
private function setWorkflowStage(
        WorkflowStageBehavior $document,
        DocumentAccessor $accessor,
        $workflowStage,
        $locale,
        $live
    ) {
        $path = $this->documentInspector->getPath($document);
        $document->setWorkflowStage($workflowStage);

        $publishDate = $document->getPublished();

        if (!$publishDate && WorkflowStage::PUBLISHED === $workflowStage) {
            $publishDate = new \DateTime();
            $accessor->set(self::PUBLISHED_FIELD, $publishDate);
        }

        $defaultNode = $this->defaultSession->getNode($path);
        $this->setWorkflowStageOnNode($defaultNode, $locale, $workflowStage, $publishDate);

        if ($live) {
            $liveNode = $this->liveSession->getNode($path);
            $this->setWorkflowStageOnNode($liveNode, $locale, $workflowStage, $publishDate);
        }
    }
private function setWorkflowStage ( WorkflowStageBehavior $ document , DocumentAccessor $ accessor , $ workflowStage , $ locale , $ live ) { $ path = $ this -> documentInspector -> getPath ( $ document ) ; $ document -> setWorkflowStage ( $ workflowStage ) ; $ publishDate = $ document -> getPublished ( ) ; if ( ! $ publishDate && WorkflowStage :: PUBLISHED === $ workflowStage ) { $ publishDate = new \ DateTime ( ) ; $ accessor -> set ( self :: PUBLISHED_FIELD , $ publishDate ) ; } $ defaultNode = $ this -> defaultSession -> getNode ( $ path ) ; $ this -> setWorkflowStageOnNode ( $ defaultNode , $ locale , $ workflowStage , $ publishDate ) ; if ( $ live ) { $ liveNode = $ this -> liveSession -> getNode ( $ path ) ; $ this -> setWorkflowStageOnNode ( $ liveNode , $ locale , $ workflowStage , $ publishDate ) ; } }
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
Sets the workflow properties on the given document .