Exemplo n.º 1
1
 /**
  * Check if the given emitter has the provided event listener.
  *
  * @param EmitterInterface $emitter Emitter to search
  * @param string|object    $value   Can be a class name or listener object
  * @param null             $event   Specific event to search (optional)
  *
  * @return bool
  */
 public static function hasListener(EmitterInterface $emitter, $value, $event = null)
 {
     $expression = $event ? '[*][0]' : '*[*][0]';
     $listeners = $event ? $emitter->listeners($event) : $emitter->listeners();
     $result = JmesPath::search($expression, $listeners) ?: [];
     if (!is_object($value)) {
         $result = array_map(function ($o) {
             return get_class($o);
         }, $result);
     }
     return in_array($value, $result, true);
 }
 public static function _apply_validate($value, array &$args, EmitterInterface $em)
 {
     if ($value === true) {
         $em->attach(new Validation($args['api'], new Validator()));
     }
 }