I know with ZF1 you would retrieve the module/controller name using custom View Helpers that would get the singleton frontController object and get the name there.
U
I created CurrentRoute View Helper for this purpose.
Install it:
composer require tasmaniski/zf2-current-route
Register module in config/application.config.php:
'modules' => array(
'...',
'CurrentRoute'
),
Use it in any view/layout file:
$this->currentRoute()->getController(); // return current controller name
$this->currentRoute()->getAction(); // return current action name
$this->currentRoute()->getModule(); // return current module name
$this->currentRoute()->getRoute(); // return current route name
You can see full documentation and code https://github.com/tasmaniski/zf2-current-route