Esempio n. 1
0
 /**
  * @param string   $name
  * @param \Closure $callable
  * @param array    $args
  * @throws \InvalidArgumentException
  */
 public function register($name, \Closure $callable, $args = [])
 {
     StringValidator::hasTo($name, 'name');
     ArrayValidator::hasTo($args, 'args');
     $this->services[$name] = ['callable' => $callable, 'args' => $args];
 }
Esempio n. 2
0
 /**
  * @param int $handler
  * @param array $args
  * @throws \InvalidArgumentException
  */
 protected function trigger($handler, $args = [])
 {
     IntegerValidator::hasTo($handler, 'handler');
     if (isset($this->eventHandler[$handler])) {
         $eventHandler = $this->eventHandler[$handler];
         ArrayValidator::hasTo($eventHandler, 'eventHandler');
         foreach ($eventHandler as $handler) {
             CallableValidator::hasTo($handler, 'handler');
             call_user_func_array($handler, $args);
         }
     }
 }