src/Sulu/Component/Content/Document/Subscriber/ShadowLocaleSubscriber.php
public function handleHydrate(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof ShadowLocaleBehavior || !$event->getOption('load_shadow_content')) {
            return;
        }

        $node = $event->getNode();
        $locale = $this->inspector->getOriginalLocale($document);
        $shadowLocaleEnabled = $this->getShadowLocaleEnabled($node, $locale);
        $document->setShadowLocaleEnabled($shadowLocaleEnabled);

        if (!$shadowLocaleEnabled) {
            return;
        }

        $shadowLocale = $this->getShadowLocale($node, $locale);
        $document->setShadowLocale($shadowLocale);
        $event->setLocale($shadowLocale);
        $document->setLocale($shadowLocale);
    }
public function handleHydrate(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof ShadowLocaleBehavior || !$event->getOption('load_shadow_content')) {
            return;
        }

        $node = $event->getNode();
        $locale = $this->inspector->getOriginalLocale($document);
        $shadowLocaleEnabled = $this->getShadowLocaleEnabled($node, $locale);
        $document->setShadowLocaleEnabled($shadowLocaleEnabled);

        if (!$shadowLocaleEnabled) {
            return;
        }

        $shadowLocale = $this->getShadowLocale($node, $locale);
        $document->setShadowLocale($shadowLocale);
        $event->setLocale($shadowLocale);
        $document->setLocale($shadowLocale);
    }
public function handleHydrate ( AbstractMappingEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof ShadowLocaleBehavior || ! $ event -> getOption ( 'load_shadow_content' ) ) { return ; } $ node = $ event -> getNode ( ) ; $ locale = $ this -> inspector -> getOriginalLocale ( $ document ) ; $ shadowLocaleEnabled = $ this -> getShadowLocaleEnabled ( $ node , $ locale ) ; $ document -> setShadowLocaleEnabled ( $ shadowLocaleEnabled ) ; if ( ! $ shadowLocaleEnabled ) { return ; } $ shadowLocale = $ this -> getShadowLocale ( $ node , $ locale ) ; $ document -> setShadowLocale ( $ shadowLocale ) ; $ event -> setLocale ( $ shadowLocale ) ; $ document -> setLocale ( $ shadowLocale ) ; }
Update the locale to the shadow locale, if it is enabled.

Note that this should happen before the fallback locale has been resolved

@param AbstractMappingEvent $event
Update the locale to the shadow locale if it is enabled .