/**
  * @param ObjectEvent $event
  */
 public function onPostDeserialize(ObjectEvent $event)
 {
     $document = $event->getObject();
     if (!$document instanceof PageDocument) {
         return;
     }
     if (!$document->getUuid()) {
         return;
     }
     try {
         $node = $this->session->getNodeByIdentifier($document->getUuid());
     } catch (ItemNotFoundException $e) {
         return;
     }
     if ($this->registry->hasNode($node)) {
         $registeredDocument = $this->registry->getDocumentForNode($node);
         $this->registry->deregisterDocument($registeredDocument);
     }
     // TODO use the original locale somehow
     $this->registry->registerDocument($document, $node, $document->getLocale());
 }
Beispiel #2
0
 /**
  * @param ObjectEvent $event
  */
 public function onPostDeserialize(ObjectEvent $event)
 {
     $document = $event->getObject();
     // only register documents
     if (!$this->metadataFactory->hasMetadataForClass(get_class($document))) {
         return;
     }
     if (!$document->getUuid()) {
         return;
     }
     try {
         $node = $this->nodeManager->find($document->getUuid());
     } catch (DocumentNotFoundException $e) {
         return;
     }
     if ($this->registry->hasNode($node, $document->getLocale())) {
         $registeredDocument = $this->registry->getDocumentForNode($node, $document->getLocale());
         $this->registry->deregisterDocument($registeredDocument);
     }
     // TODO use the original locale somehow
     if (!$this->registry->hasDocument($document)) {
         $this->registry->registerDocument($document, $node, $document->getLocale());
     }
 }
 /**
  * Deregister removed documents.
  *
  * @param RemoveEvent $event
  */
 public function handleRemove(RemoveEvent $event)
 {
     $document = $event->getDocument();
     $this->documentRegistry->deregisterDocument($document);
 }
 /**
  * It should deregister the document on the REMOVE event.
  */
 public function testHandleRemove()
 {
     $this->removeEvent->getDocument()->willReturn($this->document);
     $this->registry->deregisterDocument($this->document)->shouldBeCalled();
     $this->subscriber->handleRemove($this->removeEvent->reveal());
 }