src/core/WebCtrlResolver.php
protected function createCtrl(): AbstractCtrl
    {
        $view              = ViewFactory::createView(
            str_replace('action', '', $this->actionName),
            $this->ctrlName
        );
        $componentsRootMap = AppHelper::getInstance()->getConfig('componentsRootMap');
        if (!isset($componentsRootMap['controllers'])) {
            throw new Exception("The field 'componentsRootMap.controllers' must be "
                .'presented in the main configuration file.');
        }
        $ctrlNamespace = str_replace(
            \DIRECTORY_SEPARATOR,
            '\\',
            $componentsRootMap['controllers']
        );
        $ctrlFullName  = $ctrlNamespace.'\\'.$this->ctrlName;
        if (!is_null($view)) {
            $layoutName = AppHelper::getInstance()->getConfig('defaultLayout');
            if (!is_null($layoutName)) {
                $layout = ViewFactory::createLayout($layoutName, $view);
                $ctrl   = new $ctrlFullName($this->request, $layout);
            } else {
                $ctrl = new $ctrlFullName($this->request, $view);
            }
        } else {
            $ctrl = new $ctrlFullName($this->request);
        }
        return $ctrl;
    }
protected function createCtrl(): AbstractCtrl
    {
        $view              = ViewFactory::createView(
            str_replace('action', '', $this->actionName),
            $this->ctrlName
        );
        $componentsRootMap = AppHelper::getInstance()->getConfig('componentsRootMap');
        if (!isset($componentsRootMap['controllers'])) {
            throw new Exception("The field 'componentsRootMap.controllers' must be "
                .'presented in the main configuration file.');
        }
        $ctrlNamespace = str_replace(
            \DIRECTORY_SEPARATOR,
            '\\',
            $componentsRootMap['controllers']
        );
        $ctrlFullName  = $ctrlNamespace.'\\'.$this->ctrlName;
        if (!is_null($view)) {
            $layoutName = AppHelper::getInstance()->getConfig('defaultLayout');
            if (!is_null($layoutName)) {
                $layout = ViewFactory::createLayout($layoutName, $view);
                $ctrl   = new $ctrlFullName($this->request, $layout);
            } else {
                $ctrl = new $ctrlFullName($this->request, $view);
            }
        } else {
            $ctrl = new $ctrlFullName($this->request);
        }
        return $ctrl;
    }
It creates the controller object, assignes it with default view and layout
objects.
@return \nadir2\core\AWebController
@throws \nadir2\core\Exception It's thrown if the 'componentsRootMap.controllers'
field not presented in the main config.