Exemple #1
0
 /**
  * 获取渲染引擎
  *
  * @param string $engine 视图引擎 内置html/json/xml/excel
  *
  * @return \Cml\View\Html
  */
 public static function getEngine($engine = null)
 {
     is_null($engine) && ($engine = Config::get('view_render_engine'));
     return Cml::getContainer()->make('view_' . strtolower($engine));
 }
Exemple #2
0
 /**
  * 获取Lock实例
  *
  * @param string|null $useCache 使用的锁的配置
  *
  * @return \Cml\Lock\Redis | \Cml\Lock\Memcache | \Cml\Lock\File | false
  * @throws \Exception
  */
 public static function getLocker($useCache = null)
 {
     return Cml::getContainer()->make('cml_lock', $useCache);
 }
Exemple #3
0
 /**
  * 获取cache实例
  *
  * @param string $conf 使用的缓存配置;
  *
  * @return \Cml\Cache\Redis | \Cml\Cache\Apc | \Cml\Cache\File | \Cml\Cache\Memcache
  */
 public function cache($conf = 'default_cache')
 {
     if (is_array($conf)) {
         $config = $conf;
         $conf = md5(json_encode($conf));
     } else {
         $config = Config::get($conf);
     }
     if (isset(self::$cacheInstance[$conf])) {
         return self::$cacheInstance[$conf];
     } else {
         if ($config['on']) {
             self::$cacheInstance[$conf] = Cml::getContainer()->make('cache_' . strtolower($config['driver']), $config);
             return self::$cacheInstance[$conf];
         } else {
             throw new \InvalidArgumentException(Lang::get('_NOT_OPEN_', $conf));
         }
     }
 }
Exemple #4
0
 /**
  * 访问Cml::getContainer()->make('cml_queue')中其余方法
  *
  * @param string $name
  * @param array $arguments
  *
  * @return mixed
  */
 public static function __callStatic($name, $arguments)
 {
     return call_user_func_array([Cml::getContainer()->make('cml_queue'), $name], $arguments);
 }