src/Event/Subscriber/AdminSubscriber.php
public function loadEntities(EntityEvent $event)
    {
        $admin = $event->getAdmin();
        $configuration = $admin->getConfiguration();
        $actionConfiguration = $admin->getAction()->getConfiguration();

        $dataProvider = $this->dataProviderFactory->get($configuration->getParameter('data_provider'));
        $strategy = $actionConfiguration->getParameter('load_strategy');
        $class = $configuration->getParameter('entity');

        if (LAGAdminBundle::LOAD_STRATEGY_NONE === $strategy) {
            return;
        } elseif (LAGAdminBundle::LOAD_STRATEGY_MULTIPLE === $strategy) {
            $entities = $dataProvider->getCollection($admin, $event->getFilters());
            $event->setEntities($entities);
        } elseif (LAGAdminBundle::LOAD_STRATEGY_UNIQUE === $strategy) {
            $requirements = $actionConfiguration->getParameter('route_requirements');
            $identifier = null;

            foreach ($requirements as $name => $requirement) {
                if (null !== $event->getRequest()->get($name)) {
                    $identifier = $event->getRequest()->get($name);
                    break;
                }
            }

            if (null === $identifier) {
                throw new Exception('Unable to find a identifier for the class "'.$class.'"');
            }
            $entity = $dataProvider->get($admin, $identifier);

            $event->setEntities(new ArrayCollection([
                $entity,
            ]));
        }
    }
public function loadEntities(EntityEvent $event)
    {
        $admin = $event->getAdmin();
        $configuration = $admin->getConfiguration();
        $actionConfiguration = $admin->getAction()->getConfiguration();

        $dataProvider = $this->dataProviderFactory->get($configuration->getParameter('data_provider'));
        $strategy = $actionConfiguration->getParameter('load_strategy');
        $class = $configuration->getParameter('entity');

        if (LAGAdminBundle::LOAD_STRATEGY_NONE === $strategy) {
            return;
        } elseif (LAGAdminBundle::LOAD_STRATEGY_MULTIPLE === $strategy) {
            $entities = $dataProvider->getCollection($admin, $event->getFilters());
            $event->setEntities($entities);
        } elseif (LAGAdminBundle::LOAD_STRATEGY_UNIQUE === $strategy) {
            $requirements = $actionConfiguration->getParameter('route_requirements');
            $identifier = null;

            foreach ($requirements as $name => $requirement) {
                if (null !== $event->getRequest()->get($name)) {
                    $identifier = $event->getRequest()->get($name);
                    break;
                }
            }

            if (null === $identifier) {
                throw new Exception('Unable to find a identifier for the class "'.$class.'"');
            }
            $entity = $dataProvider->get($admin, $identifier);

            $event->setEntities(new ArrayCollection([
                $entity,
            ]));
        }
    }
public function loadEntities ( EntityEvent $ event ) { $ admin = $ event -> getAdmin ( ) ; $ configuration = $ admin -> getConfiguration ( ) ; $ actionConfiguration = $ admin -> getAction ( ) -> getConfiguration ( ) ; $ dataProvider = $ this -> dataProviderFactory -> get ( $ configuration -> getParameter ( 'data_provider' ) ) ; $ strategy = $ actionConfiguration -> getParameter ( 'load_strategy' ) ; $ class = $ configuration -> getParameter ( 'entity' ) ; if ( LAGAdminBundle :: LOAD_STRATEGY_NONE === $ strategy ) { return ; } elseif ( LAGAdminBundle :: LOAD_STRATEGY_MULTIPLE === $ strategy ) { $ entities = $ dataProvider -> getCollection ( $ admin , $ event -> getFilters ( ) ) ; $ event -> setEntities ( $ entities ) ; } elseif ( LAGAdminBundle :: LOAD_STRATEGY_UNIQUE === $ strategy ) { $ requirements = $ actionConfiguration -> getParameter ( 'route_requirements' ) ; $ identifier = null ; foreach ( $ requirements as $ name => $ requirement ) { if ( null !== $ event -> getRequest ( ) -> get ( $ name ) ) { $ identifier = $ event -> getRequest ( ) -> get ( $ name ) ; break ; } } if ( null === $ identifier ) { throw new Exception ( 'Unable to find a identifier for the class "' . $ class . '"' ) ; } $ entity = $ dataProvider -> get ( $ admin , $ identifier ) ; $ event -> setEntities ( new ArrayCollection ( [ $ entity , ] ) ) ; } }
Load entities into the event data to pass them to the Admin.

@param EntityEvent $event

@throws Exception
Load entities into the event data to pass them to the Admin .