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

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

        $node = $event->getNode();
        $property = $this->getResourceSegmentProperty($document);

        if (!$property) {
            // do not set a resource segment if the document has no structure
            return;
        }

        $locale = $this->documentInspector->getOriginalLocale($document);
        $segment = $node->getPropertyValueWithDefault(
            $this->encoder->localizedSystemName(
                $property->getName(),
                $locale
            ),
            ''
        );

        $document->setResourceSegment($segment);
    }
public function handleHydrate(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();

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

        $node = $event->getNode();
        $property = $this->getResourceSegmentProperty($document);

        if (!$property) {
            // do not set a resource segment if the document has no structure
            return;
        }

        $locale = $this->documentInspector->getOriginalLocale($document);
        $segment = $node->getPropertyValueWithDefault(
            $this->encoder->localizedSystemName(
                $property->getName(),
                $locale
            ),
            ''
        );

        $document->setResourceSegment($segment);
    }
public function handleHydrate ( AbstractMappingEvent $ event ) { $ document = $ event -> getDocument ( ) ; if ( ! $ this -> supports ( $ document ) ) { return ; } $ node = $ event -> getNode ( ) ; $ property = $ this -> getResourceSegmentProperty ( $ document ) ; if ( ! $ property ) { // do not set a resource segment if the document has no structure return ; } $ locale = $ this -> documentInspector -> getOriginalLocale ( $ document ) ; $ segment = $ node -> getPropertyValueWithDefault ( $ this -> encoder -> localizedSystemName ( $ property -> getName ( ) , $ locale ) , '' ) ; $ document -> setResourceSegment ( $ segment ) ; }
Sets the ResourceSegment of the document.

@param AbstractMappingEvent $event
Sets the ResourceSegment of the document .