Esempio n. 1
0
 /**
  * Create a class based listener using the IoC container.
  *
  * @param  mixed $listener
  *
  * @return \Closure
  */
 private function create_class_listener($listener)
 {
     $container = $this->forge->container();
     return function () use($listener, $container) {
         // If the listener has an @ sign, we will assume it is being used to delimit
         // the class name from the handle method name. This allows for handlers
         // to run multiple handler methods in a single class for convenience.
         $segments = explode('@', $listener);
         $method = count($segments) == 2 ? $segments[1] : 'handle';
         $callable = [$container->make($segments[0]), $method];
         // We will make a callable of the listener instance and a method that should
         // be called on that instance, then we will pass in the arguments that we
         // received in this method into this listener class instance's methods.
         $data = func_get_args();
         return call_user_func_array($callable, $data);
     };
 }