/**
  * Is should return early if the node is not managed.
  */
 public function testDocumentFromRegistryNoNode()
 {
     $this->hydrateEvent->hasDocument()->willReturn(true);
     $this->hydrateEvent->getNode()->willReturn($this->node->reveal());
     $this->registry->hasNode($this->node->reveal())->willReturn(false);
     $this->subscriber->handleDocumentFromRegistry($this->hydrateEvent->reveal());
 }
 /**
  * @param HydrateEvent $event
  */
 public function handleHydrate(HydrateEvent $event)
 {
     // don't need to instantiate the document if it is already existing.
     if ($event->hasDocument()) {
         return;
     }
     $node = $event->getNode();
     $document = $this->getDocumentFromNode($node);
     $event->setDocument($document);
 }
 /**
  * Stop propagation if the document is already loaded in the requested locale,
  * otherwise reset the document locale to the new locale.
  *
  * @param HydrateEvent $event
  */
 public function handleStopPropagationAndResetLocale(HydrateEvent $event)
 {
     if (!$event->hasDocument()) {
         return;
     }
     $locale = $event->getLocale();
     $document = $event->getDocument();
     $originalLocale = $this->documentRegistry->getOriginalLocaleForDocument($document);
     if (true === $this->documentRegistry->isHydrated($document) && $originalLocale === $locale) {
         $event->stopPropagation();
         return;
     }
     $this->documentRegistry->updateLocale($document, $locale, $locale);
 }