Closed seihb closed 8 years ago
Hello @seihb, sorry for delay in response.
To take a module name is really tricky. If we take a look in route config in ZfcUser/config/module.config.php
'login' => array(
'type' => 'Literal',
'options' => array(
'route' => '/login',
'defaults' => array(
'controller' => 'zfcuser',
'action' => 'login',
),
),
),
Unfortunately there is no "NAMESPACE\" key which can provide the module name. Also for controller name they are using alias 'zfcuser' not FQCN eg. "ZfcUser\Controller\UserController" which we can use to extract module name.
And because of that it's not possible to get module name :(
Alternatively you can get all other information:
var_dump($this->currentRoute()->getController()); // string 'zfcuser' (length=7)
var_dump($this->currentRoute()->getAction()); // string 'register' (length=8)
var_dump($this->currentRoute()->getModule()); // string '' (length=0)
var_dump($this->currentRoute()->getRoute()); // string 'zfcuser/register' (length=16)
I recommend you to use almost always getRoute() because that information is always available.
In Third-Party-Module ZfcUser there is no value: var_dump($this->currentRoute()->getModule());