public function trigger($name, $event = null)
	{
		$this->ensureEvents();
		
		$this->ensureEventListeners();
		
		$this->bindEventListenersEvents();
		
		if (!empty($this->_events[$name])) {
		    // 增加事件处理的动态参数
		    $args = func_get_args();
		    array_shift($args);
		    
			if (!$event instanceof Event) {
				$event = new Event();
				array_unshift($args, $event);
			}
			if ($event->sender === null) {
				$event->sender = $this;
			}
			
			$event->name = $name;
			
			foreach ($this->_events[$name] as $handler) {
			    if (isset($handler[1]) && $handler[1]) {
			        $olddata = $handler[1];
			        $event->data = array_merge($olddata, $event->data);
			    }
			    
			    if (is_string($handler[0]) && strpos($handler[0], ':') === false) {
			        $callable = [$this, $handler[0]];
			    } else {
			        $callable = Ioc::resolveCallable($handler[0]);
			    }
			    
			    // call_user_func($callable, $event);
			    call_user_func_array($callable, $args);
			    
			    // stop further handling if the event is handled
			    if ($event->isPropagationStopped()) {
			        return;
			    }
			}
		}
		
		// invoke class-level attached handlers
		Event::trigger($this, $name, $event);
	}
public function trigger($name, $event = null)
	{
		$this->ensureEvents();
		
		$this->ensureEventListeners();
		
		$this->bindEventListenersEvents();
		
		if (!empty($this->_events[$name])) {
		    // 增加事件处理的动态参数
		    $args = func_get_args();
		    array_shift($args);
		    
			if (!$event instanceof Event) {
				$event = new Event();
				array_unshift($args, $event);
			}
			if ($event->sender === null) {
				$event->sender = $this;
			}
			
			$event->name = $name;
			
			foreach ($this->_events[$name] as $handler) {
			    if (isset($handler[1]) && $handler[1]) {
			        $olddata = $handler[1];
			        $event->data = array_merge($olddata, $event->data);
			    }
			    
			    if (is_string($handler[0]) && strpos($handler[0], ':') === false) {
			        $callable = [$this, $handler[0]];
			    } else {
			        $callable = Ioc::resolveCallable($handler[0]);
			    }
			    
			    // call_user_func($callable, $event);
			    call_user_func_array($callable, $args);
			    
			    // stop further handling if the event is handled
			    if ($event->isPropagationStopped()) {
			        return;
			    }
			}
		}
		
		// invoke class-level attached handlers
		Event::trigger($this, $name, $event);
	}
public function trigger ( $ name , $ event = null ) { $ this -> ensureEvents ( ) ; $ this -> ensureEventListeners ( ) ; $ this -> bindEventListenersEvents ( ) ; if ( ! empty ( $ this -> _events [ $ name ] ) ) { // 增加事件处理的动态参数 $ args = func_get_args ( ) ; array_shift ( $ args ) ; if ( ! $ event instanceof Event ) { $ event = new Event ( ) ; array_unshift ( $ args , $ event ) ; } if ( $ event -> sender === null ) { $ event -> sender = $ this ; } $ event -> name = $ name ; foreach ( $ this -> _events [ $ name ] as $ handler ) { if ( isset ( $ handler [ 1 ] ) && $ handler [ 1 ] ) { $ olddata = $ handler [ 1 ] ; $ event -> data = array_merge ( $ olddata , $ event -> data ) ; } if ( is_string ( $ handler [ 0 ] ) && strpos ( $ handler [ 0 ] , ':' ) === false ) { $ callable = [ $ this , $ handler [ 0 ] ] ; } else { $ callable = Ioc :: resolveCallable ( $ handler [ 0 ] ) ; } // call_user_func($callable, $event); call_user_func_array ( $ callable , $ args ) ; // stop further handling if the event is handled if ( $ event -> isPropagationStopped ( ) ) { return ; } } } // invoke class-level attached handlers Event :: trigger ( $ this , $ name , $ event ) ; }
trigger named event
@param  string $name
@param  Event|array $event
@return void
trigger named event