Exemple #1
0
 /**
  * イベントの作成
  *
  * @param array|string $tag
  * @param array $params
  * @param object|null $subject
  */
 public static function create($tag, $params = [], $subject = null)
 {
     $e = new Event();
     if (!is_array($tag)) {
         $tag = [$tag];
     }
     foreach ($tag as $t) {
         $e->addTag($t);
     }
     $e->_params = $params;
     $e->setSubject($subject);
     return $e;
 }
Exemple #2
0
 public function dispatch(EventIF $event)
 {
     if (!$event->hasSubject()) {
         $event->setSubject($this->_subject);
     }
     foreach ($this->_observer_store as $observer) {
         // 伝搬チェック
         if ($event->isStopPropagation()) {
             break;
         }
         $observer->notify($event);
     }
     if (!$event->match('event.dispatched')) {
         $this->dispatch(Event::create('event.dispatched', ['event' => $event]));
     }
     return $event;
 }