mount() public static method

挂载插件到钩子 \Cml\Plugin::mount('hookName', [ function() {//匿名函数 }, '\App\Test\Plugins' => 'run' //对象, '\App\Test\Plugins::run'////静态方法 ]);
public static mount ( string $hook, array $params = [] )
$hook string 要挂载的目标钩子
$params array 相应参数
Exemplo n.º 1
0
 /**
  * 未找到控制器的时候设置勾子
  *
  */
 public static function montFor404Page()
 {
     Plugin::mount('cml.before_show_404_page', [function () {
         $cmdLists = Config::get('cmlframework_system_command');
         $cmd = strtolower(trim(Cml::getContainer()->make('cml_route')->getAppName(), '/'));
         if (isset($cmdLists[$cmd])) {
             call_user_func($cmdLists[$cmd]);
         }
     }]);
     Plugin::hook('cml.before_show_404_page');
 }
Exemplo n.º 2
0
Arquivo: Cml.php Projeto: dlpc/cmlphp
 /**
  * 未找到控制器的时候设置勾子
  *
  */
 public static function montFor404Page()
 {
     Plugin::mount('cml.before_show_404_page', array(function () {
         $cmdLists = Config::get('cmlframework_system_command');
         $cmd = trim(Route::$urlParams['path'], DIRECTORY_SEPARATOR);
         if (isset($cmdLists[$cmd])) {
             call_user_func($cmdLists[$cmd]);
         }
     }));
     Plugin::hook('cml.before_show_404_page');
 }