Пример #1
0
 /**
  * Determines if the given document is supported by this subscriber.
  *
  * @param HydrateEvent|PublishEvent|PersistEvent $event
  *
  * @return bool
  */
 private function supports($event)
 {
     return $event->getLocale() && $event->getDocument() instanceof WorkflowStageBehavior;
 }
Пример #2
0
 /**
  * Creates or updates the route for the document.
  *
  * @param PublishEvent $event
  */
 public function handlePersistRoute(PublishEvent $event)
 {
     /** @var ResourceSegmentBehavior $document */
     $document = $event->getDocument();
     if (!$this->supports($document)) {
         return;
     }
     if (!$event->getLocale()) {
         return;
     }
     if ($document instanceof HomeDocument) {
         return;
     }
     if ($document instanceof RedirectTypeBehavior && $document->getRedirectType() !== RedirectType::NONE) {
         return;
     }
     $this->persistRoute($document);
 }
Пример #3
0
 /**
  * Handles the history field for the route on publish.
  *
  * @param PublishEvent $event
  */
 public function handlePublish(PublishEvent $event)
 {
     $document = $event->getDocument();
     if (!$document instanceof RouteBehavior) {
         return;
     }
     $event->getNode()->setProperty(self::NODE_HISTORY_FIELD, $document->isHistory());
 }
Пример #4
0
 /**
  * Invalidates the assigned structure and all urls in the locale of the document of an already published document
  * when it gets republished (eg on content change).
  * This method is executed before the actual publishing of the document to avoid purging new urls.
  *
  * @param PublishEvent $event
  */
 public function invalidateDocumentBeforePublishing(PublishEvent $event)
 {
     $document = $event->getDocument();
     if ($document instanceof StructureBehavior) {
         $this->invalidateDocumentStructure($document);
     }
     if ($document instanceof ResourceSegmentBehavior && $document instanceof WorkflowStageBehavior && $document->getPublished()) {
         $this->invalidateDocumentUrls($document, $this->documentInspector->getLocale($document));
     }
 }
Пример #5
0
 /**
  * Indexes a published document.
  *
  * @param PublishEvent $event
  */
 public function indexPublishedDocument(PublishEvent $event)
 {
     $this->indexDocument($event->getDocument());
 }
Пример #6
0
 /**
  * Sets the node from the live workspace on the given event.
  *
  * @param PublishEvent|UnpublishEvent $event
  */
 private function setNodeFromPublicWorkspace($event)
 {
     $event->setNode($this->getLiveNode($event->getDocument()));
 }