%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/bbw/farmaci/kritik-portale/module/Backend/
Upload File :
Create Path :
Current File : /var/www/html/bbw/farmaci/kritik-portale/module/Backend/Module.php

<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
 * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Backend;

use Backend\Listener\ViewModelTerminationListener;
use Zend\ModuleManager\ModuleEvent;
use Zend\ModuleManager\ModuleManager;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
use Zend\I18n\Translator\Translator;

class Module
{

    public function init(ModuleManager $moduleManager)
    {
        /**
         * register listener EVENT_LOAD_MODULES_POST, this occurs after EVENT_MERGE_CONFIG but before EVENT_BOOTSTRAP
         * to enable us to edit configuration keys with localized information
        **/
        $eventManager = $moduleManager->getEventManager();
        $eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, [$this, 'onLoadModulesPost']);
    }

    public function onBootstrap(MvcEvent $e)
    {
        $eventManager        = $e->getApplication()->getEventManager();
        $sharedManager       = $eventManager->getSharedManager();
        $serviceManager      = $e->getApplication()->getServiceManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        /**
         * attach event needed for the ViewModelTermination-Listener
         * The ViewModelTermination-Listener will set the view-Models terminate
         * status according to the type of request used. If its an AJAX request
         * only the appropriate action response view model should be rendered
         * while we use SmartAdmin
         */
        //$eventManager = $e->getTarget()->getEventManager();
        $eventManager->attach(new ViewModelTerminationListener());
        
        $sharedManager->attach('Zend\Mvc\Controller\AbstractController', 'dispatch', function($e) use ($serviceManager) {
            $controller      = $e->getTarget();
            $controllerClass = get_class($controller);
            $moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
            $config          = $e->getApplication()->getServiceManager()->get('config');
            if (isset($config['module_layouts'][$moduleNamespace])) {
                $controller->layout($config['module_layouts'][$moduleNamespace]);
            }
        }, 100);
    }

    public function onLoadModulesPost(ModuleEvent $e)
    {
        $configListener = $e->getConfigListener();
        $serviceManager = $e->getParam('ServiceManager');
        $translator     = $serviceManager->get('translator');
        $config         = $configListener->getMergedConfig(false);

        //apply translation to configuration
        if (isset($config['navigation']['backend'])) {
            $config['navigation']['backend'][0]['label'] = $translator->translate("Dashboard");
            $config['navigation']['backend'][1]['label'] = $translator->translate("Configuration");
            $config['navigation']['backend'][1]['pages'][0]['label'] = $translator->translate("User Management");
        }
        // Pass the changed configuration back to the listener
        $configListener->setMergedConfig($config);
        $serviceManager->setAllowOverride(true);
        $serviceManager->setService('Config', $config);
        $serviceManager->setAllowOverride(false);
    }

    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__,
                ),
            ),
        );
    }

    public function getDatatableConfig()
    {
        return include __DIR__ . '/config/datatable.config.php';
    }
}

Zerion Mini Shell 1.0