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

        if (!$document instanceof ShadowLocaleBehavior) {
            return;
        }

        if (!$document->isShadowLocaleEnabled()) {
            return;
        }

        $node = $event->getNode();
        $structure = $this->inspector->getStructureMetadata($document);

        if (false === $structure->hasPropertyWithTagName('sulu.rlp')) {
            return;
        }

        $locatorProperty = $structure->getPropertyByTagName('sulu.rlp');

        if ($node->getPropertyValueWithDefault(
            $this->encoder->localizedSystemName(
                $locatorProperty->getName(), $document->getLocale()
            ),
            null
        )) {
            return;
        }

        $shadowLocator = $node->getPropertyValueWithDefault(
            $this->encoder->localizedSystemName(
                $locatorProperty->getName(), $document->getShadowLocale()
            ),
            null
        );

        if (!$shadowLocator) {
            return;
        }

        $event->getAccessor()->set(
          'resourceSegment',
          $shadowLocator
        );
    }
public function handlePersistUpdateUrl(PersistEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof ShadowLocaleBehavior) {
            return;
        }

        if (!$document->isShadowLocaleEnabled()) {
            return;
        }

        $node = $event->getNode();
        $structure = $this->inspector->getStructureMetadata($document);

        if (false === $structure->hasPropertyWithTagName('sulu.rlp')) {
            return;
        }

        $locatorProperty = $structure->getPropertyByTagName('sulu.rlp');

        if ($node->getPropertyValueWithDefault(
            $this->encoder->localizedSystemName(
                $locatorProperty->getName(), $document->getLocale()
            ),
            null
        )) {
            return;
        }

        $shadowLocator = $node->getPropertyValueWithDefault(
            $this->encoder->localizedSystemName(
                $locatorProperty->getName(), $document->getShadowLocale()
            ),
            null
        );

        if (!$shadowLocator) {
            return;
        }

        $event->getAccessor()->set(
          'resourceSegment',
          $shadowLocator
        );
    }
public function handlePersistUpdateUrl ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ document instanceof ShadowLocaleBehavior ) { return ; } if ( ! $ document -> isShadowLocaleEnabled ( ) ) { return ; } $ node = $ event -> getNode ( ) ; $ structure = $ this -> inspector -> getStructureMetadata ( $ document ) ; if ( false === $ structure -> hasPropertyWithTagName ( 'sulu.rlp' ) ) { return ; } $ locatorProperty = $ structure -> getPropertyByTagName ( 'sulu.rlp' ) ; if ( $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedSystemName ( $ locatorProperty -> getName ( ) , $ document -> getLocale ( ) ) , null ) ) { return ; } $ shadowLocator = $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedSystemName ( $ locatorProperty -> getName ( ) , $ document -> getShadowLocale ( ) ) , null ) ; if ( ! $ shadowLocator ) { return ; } $ event -> getAccessor ( ) -> set ( 'resourceSegment' , $ shadowLocator ) ; }
If this is a shadow document, update the URL to that of the shadowed document.

TODO: This is about caching and should be handled somewhere else.

@param PersistEvent $event
If this is a shadow document update the URL to that of the shadowed document .