forked from EvanDotPro/EdpModuleLayouts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathModule.php
More file actions
22 lines (21 loc) · 902 Bytes
/
Module.php
File metadata and controls
22 lines (21 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php
namespace EdpModuleLayouts;
class Module
{
public function onBootstrap($e)
{
$e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\Mvc\Controller\AbstractController', 'dispatch', function($e) {
$controller = $e->getTarget();
$controllerClass = get_class($controller);
$config = $e->getApplication()->getServiceManager()->get('config');
if (isset($config['module_layouts'][$controllerClass])) {
$controller->layout($config['module_layouts'][$controllerClass]);
return;
}
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
if (isset($config['module_layouts'][$moduleNamespace])) {
$controller->layout($config['module_layouts'][$moduleNamespace]);
}
}, 100);
}
}