Mam problem z przełączaniem wyglądów (layoutów), mam zrobione wszystko wg dokumencji jednak coś nie działa i templeatka się nie zmienia.
class Module
{
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$application = $e->getApplication();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
$serviceManager = $application->getServiceManager();
$sessionManager = $serviceManager->get(SessionManager::class);
$sharedEventManager = $e->getParam('Managment');
$sharedEventManager = $eventManager->getSharedManager();
// Register the event listener method.
$sharedEventManager->attach(__NAMESPACE__, 'dispatch',
[$this, 'onDispatch'], 100);
}
public function onDispatch(MvcEvent $event)
{
// Get controller to which the HTTP request was dispatched.
$controller = $event->getTarget();
// Get fully qualified class name of the controller.
$controllerClass = get_class($controller);
// Get module name of the controller.
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
$matches = $event->getRouteMatch();
$controller = $matches->getParam('controller');
if (false === strpos($controller, __NAMESPACE__)) {
return;
}
// Switch layout only for controllers belonging to our module.
if ($moduleNamespace == __NAMESPACE__) {
$viewModel = $event->getViewModel();
$viewModel->setTemplate('layout/admin-layout');
}
}
oraz w IndexController
$this->layout()->setTemplate('layout/admin-layout');
niestety nie działa, nie zglasza też zadnego błedu