Distrust wrote
>
> Matus Zeman wrote
>> Why can't you simply implement it inside of showSettingsAction() method?
> Because I need a universal method to initialize various elements (before
> action), without duplicating my code in every other controller action.
> Settings were just an example.
For universal solution you may want to try this one, it will work for all
Controllers within single Module:
class Module
{
// Evan's changing layout for specific module only
public function init(ModuleManager $moduleManager) {
$sharedEvents =
$moduleManager->getEventManager()->getSharedManager();
$sharedEvents->attach(__NAMESPACE__, 'dispatch', function($e) {
$controller = $e->getTarget();
// do your stuff with controller
}, 100);
}
}
-----
Cheers,
--
Luke Mierzwa
--
View this message in context:
http://zend-framework-community.634137.n4.nabble.com/ZF2-Doing-something-before-calling-the-controller-action-tp4656922p4656934.html
Sent from the Zend Framework mailing list archive at Nabble.com.
--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]