Skip to content
Snippets Groups Projects
Select Git revision
  • bootstrap4_migration
  • master default protected
  • 5.x
  • ll-php8-bs5
  • release_5_bs5
  • ll-php8
  • 4.x
  • laminas_migration
  • release_1.0.0.2
  • release_4.0.0
  • release_3.2.8
  • 1.0.0.3
  • 6.0.7
  • 6.0.6
  • 6.0.5
  • 6.0.4
  • 6.0.3
  • 6.0.2
  • 6.0.1
  • 5.1.1
  • 6.0.0
  • 5.1.0
  • 5.0.0
  • 4.0.2
  • 3.2.11
  • 4.0.1
  • 3.2.10
  • 4.0.0
  • 1.0.0.2
  • 3.2.9
  • 3.2.8
31 results

helpers.md

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Module.php 5.26 KiB
    <?php
    /**
     * Zend Framework (http://framework.zend.com/)
     *
     * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
     * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
     * @license   http://framework.zend.com/license/new-bsd New BSD License
     */
    
    namespace Application;
    
    use Zend\Mvc\ModuleRouteListener;
    use Zend\Mvc\MvcEvent;
    use Zend\ModuleManager\Feature\ViewHelperProviderInterface;
    use Zend\ModuleManager\Feature\ControllerPluginProviderInterface;
    
    class Module implements ControllerPluginProviderInterface, ViewHelperProviderInterface
    {
        public function onBootstrap(MvcEvent $e)
        {
            $sm = $e->getApplication()->getServiceManager();
            $sm->get('translator');
            $eventManager        = $e->getApplication()->getEventManager();
            $moduleRouteListener = new ModuleRouteListener();
            $moduleRouteListener->attach($eventManager);
            
    //        $eventManager->attach(MvcEvent::EVENT_RENDER, array($this, 'registerModalStrategy'), 100);
    
            $eventManager->attach(new AuthenticatedUserSavedListener($sm->get('doctrine.entitymanager.orm_default')));
    
            /* Déclare la dernière vue transmise comme terminale si on est en AJAX */
            $sharedEvents = $eventManager->getSharedManager();
            $sharedEvents->attach('Zend\Mvc\Controller\AbstractActionController','dispatch',
                 function($e) {
                    $result = $e->getResult();
                    if(is_array($result)){
                        $result = new \Zend\View\Model\ViewModel($result);
                        $e->setResult($result);
                    }elseif(empty($result)){
                        $result = new \Zend\View\Model\ViewModel();
                        $e->setResult($result);
                    }
                    if ($result instanceof \Zend\View\Model\ViewModel) {
                        $result->setTerminal($e->getRequest()->isXmlHttpRequest());
                    }
            });
        }
        
        /**
         * @param  \Zend\Mvc\MvcEvent $e The MvcEvent instance
         * @return void
         */
        public function registerModalStrategy($e)
        {
    //        $matches    = $e->getRouteMatch();
    //        $controller = $matches->getParam('controller');
    //        if (false === strpos($controller, __NAMESPACE__)) {
    //            // not a controller from this module
    //            return;
    //        }
            if (!$e->getParam('modal', false)) {
                return;
            }
    
    //        // Potentially, you could be even more selective at this point, and test
    //        // for specific controller classes, and even specific actions or request
    //        // methods.
    
            // Set the JSON strategy when controllers from this module are selected
            $app          = $e->getTarget();
            $locator      = $app->getServiceManager();
            $view         = $locator->get('Zend\View\View');
    //        $jsonStrategy = $locator->get('ViewJsonStrategy');
            $modalStrategy = new View\Renderer\ModalStrategy();
    
            // Attach strategy, which is a listener aggregate, at high priority
            $view->getEventManager()->attach($modalStrategy, 100);
        }
        
        public function getConfig()
        {
            return include __DIR__ . '/config/module.config.php';
        }
    
        public function getAutoloaderConfig()
        {
            return array(
                'Zend\Loader\StandardAutoloader' => array(
                    'namespaces' => array(
                        __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                    ),
                ),
            );
        }
    
        /**
         * {@inheritDoc}
         */
        public function getControllerPluginConfig()
        {
            return array(
                'invokables' => array(
                    'em'      => 'Application\Controller\Plugin\Em',
                    'context' => 'Application\Controller\Plugin\Context',
                ),
                'factories' => array(
                    'intervenant'        => 'Application\Controller\Plugin\IntervenantFactory',
                    'serviceReferentiel' => 'Application\Controller\Plugin\ServiceReferentielFactory',
                ),
            );
        }
    
        /**
         * Expected to return \Zend\ServiceManager\Config object or array to
         * seed such an object.
         *
         * @return array|\Zend\ServiceManager\Config
         * @see ViewHelperProviderInterface
         */
        public function getViewHelperConfig()
        {
            return array(
                'factories'  => array(
                ),
                'invokables' => array(
                    'intervenantDl'        => 'Application\View\Helper\IntervenantDl',
                    'adresseDl'            => 'Application\View\Helper\AdresseDl',
                    'elementPedagogiqueDl' => 'Application\View\Helper\OffreFormation\ElementPedagogiqueDl',
                    'etapeDl'              => 'Application\View\Helper\OffreFormation\EtapeDl',
                    'fieldsetElementPedagogiqueRecherche' => 'Application\View\Helper\OffreFormation\FieldsetElementPedagogiqueRecherche',
                ),
            );
        }
    
        /**
         *
         * @return array
         * @see ServiceProviderInterface
         */
        public function getServiceConfig()
        {
             return array(
                'invokables' => array(
                    'ApplicationOffreFormation' => 'Application\\Service\\OffreFormation',
                    'ApplicationIntervenant' => 'Application\\Service\\Intervenant',
                ),
            );
        }
    }