Ejemplo n.º 1
0
 /**
  * Create and set a new event listener.
  *
  * @param  string   $handle    action or filter handle
  * @param  callable $callback
  * @param  int      $priority
  *
  * @return Hook
  */
 function on($handle, callable $callback, $priority = 10)
 {
     return Hook::on($handle, $priority)->setCallback($callback)->listen();
 }
Ejemplo n.º 2
0
 /**
  * @test
  */
 public function it_handles_different_callable_syntaxes()
 {
     Hook::on('test_function_name_as_string')->setCallback('aNormalFunction')->listen();
     do_action('test_function_name_as_string');
     Hook::on('test_static_method_as_string')->setCallback('CallMy::staticMethod')->listen();
     do_action('test_static_method_as_string');
     Hook::on('test_static_method_as_array')->setCallback(['CallMy', 'staticMethod'])->listen();
     do_action('test_static_method_as_array');
     Hook::on('test_instance_method_as_array')->setCallback([new CallMy(), 'instanceMethod'])->listen();
     do_action('test_instance_method_as_array');
 }