コード例 #1
0
ファイル: Functions.php プロジェクト: NilsLangner/LiveTest
 public static function initializeObject($object, $parameter)
 {
     $result = '';
     if (method_exists($object, 'init')) {
         try {
             $namedParameters = new NamedParameters();
             $result = $namedParameters->callMethod($object, 'init', $parameter);
         } catch (\phmLabs\Components\NamedParameters\Exception $e) {
             throw new ConfigurationException('Unable to initialize object (' . get_class($object) . '). ' . 'Mandatory parameter "' . $e->getMissingParameter() . '" is missing.');
         }
     }
     return $result;
 }
コード例 #2
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;
 }
コード例 #3
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;
 }