Bundle/PageBundle/EventSubscriber/PageSubscriber.php
public function postLoad(LifecycleEventArgs $eventArgs)
    {
        $entity = $eventArgs->getEntity();

        if ($entity instanceof View) {
            $entity->setReferences([$entity->getCurrentLocale() => new ViewReference($entity->getId())]);
            $viewReferences = $this->viewReferenceRepository->getReferencesByParameters([
                'viewId'     => $entity->getId(),
                'templateId' => $entity->getId(),
            ], true, false, 'OR');
            foreach ($viewReferences as $viewReference) {
                if ($viewReference->getLocale() === $entity->getCurrentLocale()) {
                    if ($entity instanceof WebViewInterface && $viewReference instanceof ViewReference) {
                        $entity->setReference($viewReference, $viewReference->getLocale());
                        $entity->setUrl($viewReference->getUrl());
                    } elseif ($entity instanceof BusinessTemplate) {
                        $entity->setReferences([
                            $entity->getCurrentLocale() => $this->viewReferenceBuilder->buildViewReference($entity, $eventArgs->getEntityManager()),
                        ]);
                    }
                }
            }
        }
    }
public function postLoad(LifecycleEventArgs $eventArgs)
    {
        $entity = $eventArgs->getEntity();

        if ($entity instanceof View) {
            $entity->setReferences([$entity->getCurrentLocale() => new ViewReference($entity->getId())]);
            $viewReferences = $this->viewReferenceRepository->getReferencesByParameters([
                'viewId'     => $entity->getId(),
                'templateId' => $entity->getId(),
            ], true, false, 'OR');
            foreach ($viewReferences as $viewReference) {
                if ($viewReference->getLocale() === $entity->getCurrentLocale()) {
                    if ($entity instanceof WebViewInterface && $viewReference instanceof ViewReference) {
                        $entity->setReference($viewReference, $viewReference->getLocale());
                        $entity->setUrl($viewReference->getUrl());
                    } elseif ($entity instanceof BusinessTemplate) {
                        $entity->setReferences([
                            $entity->getCurrentLocale() => $this->viewReferenceBuilder->buildViewReference($entity, $eventArgs->getEntityManager()),
                        ]);
                    }
                }
            }
        }
    }
public function postLoad ( LifecycleEventArgs $ eventArgs ) { $ entity = $ eventArgs -> getEntity ( ) ; if ( $ entity instanceof View ) { $ entity -> setReferences ( [ $ entity -> getCurrentLocale ( ) => new ViewReference ( $ entity -> getId ( ) ) ] ) ; $ viewReferences = $ this -> viewReferenceRepository -> getReferencesByParameters ( [ 'viewId' => $ entity -> getId ( ) , 'templateId' => $ entity -> getId ( ) , ] , true , false , 'OR' ) ; foreach ( $ viewReferences as $ viewReference ) { if ( $ viewReference -> getLocale ( ) === $ entity -> getCurrentLocale ( ) ) { if ( $ entity instanceof WebViewInterface && $ viewReference instanceof ViewReference ) { $ entity -> setReference ( $ viewReference , $ viewReference -> getLocale ( ) ) ; $ entity -> setUrl ( $ viewReference -> getUrl ( ) ) ; } elseif ( $ entity instanceof BusinessTemplate ) { $ entity -> setReferences ( [ $ entity -> getCurrentLocale ( ) => $ this -> viewReferenceBuilder -> buildViewReference ( $ entity , $ eventArgs -> getEntityManager ( ) ) , ] ) ; } } } } }
If entity is a View
it will find the ViewReference related to the current view and populate its url.

@param LifecycleEventArgs $eventArgs
If entity is a View it will find the ViewReference related to the current view and populate its url .