/** * 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; }
/** * 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); }
/** * 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()); }
/** * 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)); } }
/** * Indexes a published document. * * @param PublishEvent $event */ public function indexPublishedDocument(PublishEvent $event) { $this->indexDocument($event->getDocument()); }
/** * 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())); }