Beispiel #1
0
 /**
  * Indexes a document after its draft have been removed.
  *
  * @param RemoveDraftEvent $event
  */
 public function indexDocumentAfterRemoveDraft(RemoveDraftEvent $event)
 {
     $document = $event->getDocument();
     if ($document instanceof WorkflowStageBehavior) {
         // Set the workflowstage to test for indexing, because the wrong index will be updated otherwise
         $document->setWorkflowStage(WorkflowStage::TEST);
     }
     $this->indexDocument($document);
     if ($document instanceof WorkflowStageBehavior) {
         // Reset the workflowstage to published, because after removing a draft the document will always be in
         // the published state
         $document->setWorkflowStage(WorkflowStage::PUBLISHED);
     }
 }
Beispiel #2
0
 public function copyPropertiesFromPublicWorkspace(RemoveDraftEvent $event)
 {
     $node = $event->getNode();
     $locale = $event->getLocale();
     $this->removeLocalizedNodeProperties($node, $locale);
     $liveNode = $this->getLiveNode($event->getDocument());
     // Copy all localized system and content properties from the live node
     foreach ($liveNode->getProperties($this->propertyEncoder->localizedSystemName('', $locale) . '*') as $property) {
         /** @var PropertyInterface $property */
         $node->setProperty($property->getName(), $property->getValue());
     }
     foreach ($liveNode->getProperties($this->propertyEncoder->localizedContentName('', $locale) . '*') as $property) {
         /** @var PropertyInterface $property */
         if ($node->hasProperty($property->getName())) {
             // skip the properties that have already been written by the previous loop
             // the properties haven't changed in the mean time, and writing them again would be unnecessary
             continue;
         }
         $node->setProperty($property->getName(), $property->getValue());
     }
 }