_registry = $_registry; $this->_shortcut = $_shortcut; $this->db = Database::getConnection($registry->readKey(array('system', 'dsn'))); $this->installer = new Installer($_registry); } /** * Создает экземпляр модуля и выполняет действия для него * @param string $name Имя модуля * @param request $request Имя модуля * @return string */ public function loadModule($name, Collection $request) { $this->installer->setUp($this->db, array($this, 'installPath')); $this->installer->doUpdates($name); // ModuleLoader (1) $moduleFile = Shortcut::getUrl($this->shortcut, $name); // ModuleLoader (2) $module = $this->loadClass($moduleFile); if ($module) { // Инициализация модуля // $module->viewPath = dirname($moduleFile); $module->viewPath = Shortcut::getUrl('modulepath', $name); $module->name = $name; $module->param = $this->param; // $module->_registry = $this->_registry; $module->_shortcut = $this->_shortcut; $module->iconPath = $this->iconPath; // -> Registry $module->themePath = $this->themePath; // -> Registry $module->jsPath = $this->jsPath; // -> Registry $module->db = $this->db; // Не для всех приложений нужно вести лог действий // Ведение лога $logger = $this->loadClass(FRAMEWORK_PATH . '/core/filter/actionlogger.php', $module); $logger->before = $this->loadSettings(Shortcut::getUrl('logger', $name)); // Управление доступом $module->access = $this->loadClass(FRAMEWORK_PATH . '/core/filter/actionaccess.php', $logger); $module->access->access = $this->loadSettings(Shortcut::getUrl('access', $name)); $module->setUp(); return $module->access->execute($request); } return null; // throw new FileNotFoundException(); } public function setParameter($shortcut, $param, $name) { $this->shortcut = $shortcut; // Параметр $this->_param = $param; $this->default = $name; } private function getParameter(Collection $list) { return ($list->get($this->_param)) ? $list->get($this->_param): $this->default; } public function execute(HTTPRequest $request) { return $this->loadModule($this->getParameter($request), $request); } }