コード例 #1
0
ファイル: Dispatcher.php プロジェクト: phmlabs/annovent
 /**
  * This function is used to call all listeners. It stops processing if the $until parameter is true and the
  * event is processed.
  *
  * @param Event $event
  * @param array $namedParameters
  * @param boolean $until If this param is true the event/listener chain will stop if the vent is processed.
  */
 private function processEvent(EventInterface &$event, $until = false)
 {
     $finalParameters = $event->getParameters();
     $finalParameters['event'] = $event;
     foreach ($this->getListeners($event->getName()) as $listener) {
         $result = NamedParameters::call($listener, $finalParameters);
         if ($until === true && $event->isProcessed()) {
             return $result;
         }
     }
     return null;
 }
コード例 #2
0
ファイル: Init.php プロジェクト: phmlabs/init
 public static function initialize($element)
 {
     if (!array_key_exists("class", $element)) {
         throw new \RuntimeException("the given array does not provide an element with 'class' as key");
     }
     $class = $element['class'];
     if (!class_exists($class)) {
         throw new \RuntimeException("No class with name " . $class . " found");
     }
     $object = new $class();
     if (method_exists($object, 'init')) {
         if (array_key_exists('parameters', $element)) {
             $parameters = array_merge($element['parameters'], self::$globalParameters);
         } else {
             $parameters = self::$globalParameters;
         }
         NamedParameters::call([$object, 'init'], $parameters);
     }
     return $object;
 }