/** * Выполняет инициализацию модуля * * @param array $options */ public static function initialize(array $options = array()) { if (isset($options['middleware']) && is_array($options['middleware'])) { self::$middleware = array_merge(self::$middleware, $options['middleware']); } if (isset($options['handlers']) && is_array($options['handlers'])) { self::$handlers = array_merge(self::$handlers, $options['handlers']); } }
/** * @param array $config */ static function initialize($config = array()) { try { self::$globals = new ArrayObject(); foreach ($config as $key => $value) { self::${$key} = $value; } self::add_listeners(); foreach (array('files_path', 'stdfiles_cache', 'assets_dir') as $key) { self::${$key} = str_replace('%files%', Core::option('files_name'), self::${$key}); } self::configure_paths(); self::configure_loader(); Core::load('Events'); /** * * @event cms.initialize.start * Вызывается в начале инициализации при загрузке модуля CMS. Если возвращено значение, отличное от null, то дальнейшая инициализация произведена не будет. * */ $rc = Events::call('cms.initialize.start'); if (!is_null($rc)) { return $rc; } Core::load('WS.DSL'); self::$common_application = WS_DSL::application(); self::$web_application = WS_DSL::application(); self::common_application()->cms_static(); self::dummy_run(); if (CMS::is_lazy_components()) { Core::option('spl_autoload', true); Core::register_spl_autoload(); } if (!Core::option('spl_autoload')) { spl_autoload_register('CMS::spl_autoload'); self::load(); } else { self::load(); } if (self::$enable_rest) { Core::load('WS.Services.REST'); Core::load('CMS.Application'); self::$dispatcher = new CMS_Application_Dispatcher(); WS_DSL::add_middleware('dispatcher', self::$dispatcher); } self::common_application()->config(self::$cfg_file)->cache()->db()->orm(self::$orm_root ? self::$orm_root : 'CMS.ORM.Root')->cms_configure(); //FIXME: не запускать сразу self::dummy_run(); /** * * @event cms.initialize.ready * Вызывается в конце инициализации при загрузке модуля CMS * */ $rc = Events::call('cms.initialize.ready'); if (!is_null($rc)) { return $rc; } Core::load(self::vars_module()); self::application()->session()->status(array(404 => '404', 500), 'status', true)->cms_std()->auth_apache(self::build_apache_auth_module())->auth_basic(CMS_Handlers::AuthModule(), array('env_name' => 'admin_auth'))->cms_realm_auth(); } catch (Exception $e) { self::root_catcher($e); } }