Exemplo n.º 1
0
 /**
  * 注册模型实例
  *
  * @param mixed $obj
  * @static
  * @access public
  * @return boolean
  */
 public static function set(Data $obj)
 {
     if (!self::$enabled) {
         return true;
     }
     $id = $obj->id();
     if (!$id) {
         return false;
     }
     $class = get_class($obj);
     $key = $class . $id;
     listen_event($obj, Data::AFTER_DELETE_EVENT, function () use($class, $id) {
         Registry::remove($class, $id);
     });
     return Utils\Registry::set($key, $obj);
 }
Exemplo n.º 2
0
<?php

define('ROOT_DIR', realpath(__DIR__ . '/../'));
define('DEBUG', true);
require __DIR__ . '/../../../framework/core.php';
Lysine\Utils\Profiler::instance()->start('__MAIN__');
Lysine\Config::import(require ROOT_DIR . '/config/_config.php');
app()->includePath(ROOT_DIR);
// 系统日志,根据需要开启,需要创建ROOT_DIR .'/logs'目录
//use Lysine\Utils\Logging;
//Lysine\logger()
//    ->setLevel(DEBUG ? Logging::DEBUG : Logging::ERROR)
//    ->addHandler(new Logging\FileHandler('sys_log'));
use Lysine\MVC;
listen_event(app()->getRouter(), MVC\BEFORE_DISPATCH_EVENT, array(Model\Rbac::instance(), 'check'));