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;
    }