think\Hook::import PHP Method

import() public static method

批量导入插件
public static import ( array $tags, boolean $recursive = true )
$tags array 插件信息
$recursive boolean 是否递归合并
    public static function import(array $tags, $recursive = true)
    {
        if ($recursive) {
            foreach ($tags as $tag => $behavior) {
                self::add($tag, $behavior);
            }
        } else {
            self::$tags = $tags + self::$tags;
        }
    }

Usage Example

 /**
  * @param mixed $content
  */
 public function run(&$content)
 {
     /**
      *  //真不知道说什么好。。。
      *      这里      原因是tp 不能把tag放在项目配置中,只能放在common中,而common模块先于install 初始化
      *     so。。。。。
      *
      */
     if (C('DB_TYPE') == 'GreenCMS_DB_TYPE') {
     } else {
         if (isset($_GET['m']) && strtolower($_GET['m']) == 'install') {
             return;
         }
         $data = S('hooks');
         if (!$data) {
             $hooks = M('Hooks')->getField('name,addons');
             foreach ($hooks as $key => $value) {
                 if ($value) {
                     $map['status'] = 1;
                     $names = explode(',', $value);
                     $map['name'] = array('IN', $names);
                     $data = M('Addons')->where($map)->getField('id,name');
                     if ($data) {
                         $addons = array_intersect($names, $data);
                         Hook::add($key, $addons);
                     }
                 }
             }
             S('hooks', Hook::get());
         } else {
             Hook::import($data, false);
         }
     }
 }
All Usage Examples Of think\Hook::import