sina miandashti wrote
> 
> can u please paste your working module.php code
> 
> i m having same problem  adding zend translate variable to view model
> 
just replace the following function:

public function init(Manager $moduleManager) {
        $sharedEvents = $moduleManager->events()->getSharedManager();
        $sharedEvents->attach('bootstrap', 'bootstrap', array($this,
'initializeView'), 100);
        $sharedEvents->attach('*Application*', 'dispatch', function($e) {
                $controller = $e->getTarget();
                $route = $controller->getEvent()->getRouteMatch();
                $viewModel = $controller->getEvent()->getViewModel();
                $variables = $viewModel->getVariables();
                if ( false === isset($variables['controller'])) {
                        $viewModel->setVariable('controller', 
$route->getParam('controller'));
                }
                if ( false === isset($variables['action']) ) {
                        $viewModel->setVariable('action', 
$route->getParam('action'));
                }
        },100);
}

make sure your namespace is identical to the event
<?php
namespace *Application*;
...
$sharedEvents->attach('*Application*', 'dispatch'...

--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/ZF2-Access-controller-name-action-from-layout-tp4624104p4644816.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to