예제 #1
0
파일: View.php 프로젝트: techart/tao
 protected function load_helperes_from_cache($helpers)
 {
     if (!CMS::is_lazy_components()) {
         return;
     }
     if ($this->is_cache_loaded) {
         return;
     }
     $this->is_cache_loaded = true;
     if ($classes = WS::env()->cache->get('cms:viwes:helpers_classes')) {
         foreach ($classes as $name => $class) {
             $helpers->append($class, $name);
         }
     } else {
         Events::add_once('cms.load_components', function () use($helpers) {
             WS::env()->cache->set('cms:viwes:helpers_classes', $helpers->classes, 0);
         });
         CMS::load_components();
     }
 }
예제 #2
0
파일: ORM.php 프로젝트: techart/tao
 protected function load_cache()
 {
     if (!CMS::is_lazy_components()) {
         return;
     }
     if ($this->is_cache_loaded) {
         return;
     }
     $this->is_cache_loaded = true;
     if ($classes = $this->cache->get('cms:orm:classes')) {
         $this->mappers = array_replace_recursive($classes, $this->mappers, self::$classes);
     } else {
         $self = $this;
         $cache = $this->cache;
         Events::add_once('cms.load_components', function () use($self, $cache) {
             $mappers = array_replace_recursive(CMS_ORM_Root::$classes, $self->get_mappers());
             $cache->set('cms:orm:classes', $mappers, 0);
         });
         CMS::load_components();
     }
 }
예제 #3
0
파일: CMS.php 프로젝트: techart/tao
 /**
  * @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);
     }
 }