触发一个事件

@access public
@param string $event 事件名称
@param array $data 参数
430726
public static function trigger(string $event, $data = []) {
		$result = null;
		if (isset(self::$events[$event])) {
			foreach (self::$events[$event] as $callback) {
				$result = Utils::call($callback, $data);
				if ($result !== null) {
					break;
				}
			}
		}
		return $result;
	}
679531
public function onDataReady(DataEvent $event)
    {
         
        $data  = array();
       
        foreach ($event->getData() as $key => $row){
            foreach ($row as $field => $value){
                
                if($value instanceof \DateTime){
                    $value->setTimezone(new \DateTimeZone($this->timezone));
                }
                
                $data[$key][$field] = $value;
            }
        }
        
        $event->setData($data);
    }
1087492
protected function call($eventName, $method, $data = null)
    {
        if (method_exists($this, $method)) {
            $result = call_user_func_array([$this, $method], $data);
            return $result;
        }

        return null;
    }
790010
public static function fire($event, $data = array()){

        if( !isset(self::$observers[ $event ]) ){
            return $data;
        }

        $observers = self::$observers[ $event ];

        foreach( $observers as $observer ){
            App::runMethod($observer, $data);
        }

        return $data;
    }
130318
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) {
		$field = $this->getConfig('field');
		$property = $this->getConfig('tagsAssoc.propertyName');
		$options['accessibleFields'][$property] = true;

		if (isset($data[$field])) {
			$data[$property] = $this->normalizeTags($data[$field]);
		} elseif ($field !== $property) {
			if (isset($data[$property]) && !is_array($data[$property])) {
				throw new RuntimeException('Your `' . $property . '` property is malformed (expected array instead of string). You configured to save list of tags in `' . $field . '` field.');
			}
		}

		if (isset($data[$field]) && empty($data[$field])) {
			unset($data[$field]);
		}
	}
946335
public function eventAfterDelete($event)
    {
        if ($this->isLoggable()) {
            Yii::$app->db->createCommand()->insert('{{%admin_ngrest_log}}', [
                'user_id' => $this->getUserId(),
                'timestamp_create' => time(),
                'route' => $this->route,
                'api' => $this->api,
                'is_insert' => false,
                'is_update' => false,
                'is_delete' => true,
                'attributes_json' => $this->toJson($event->sender->getAttributes()),
                'table_name' => $event->sender->tableName(),
                'pk_value' => implode("-", $event->sender->getPrimaryKey(true)),
            ])->execute();
        }
    }
817562
function trigger($type, $data)
    {
        /**
         * 异步，将事件压入队列
         */
        if (isset($this->config['async']) && $this->config['async'])
        {
            return $this->getQueueInstance()->push(array('type' => $type, 'data' => $data));
        }
        /**
         * 同步，直接在引发事件时处理
         */
        else
        {
            return $this->_execute($type, $data);
        }
    }
1009018
function onEvent($event)
    {
        if (!isset($event->data[0]['id'])) {
            throw new ClientError('Invalid event data, payment id not found.');
        }

        call_user_func($this->callback, $this->service->get($event->data[0]['id']));
    }
1091568
public function beforeMarshal(Event $event, \ArrayObject $data, \ArrayObject $options)
    {
        $this->_prepareParamsData($data);
    }
106110
public function trigger($event, $data, $id = null)
    {
        if (!isset($id)) {
            $id = $this->lastId++;
        }
        $this->putLine('event: ' . $event);
        $this->putLine('id: ' . $id);
        $this->putLine('data: ' . $data);
        $this->putLine();
        $this->flush();
    }
666787
final protected static function triggerEvent($event, array $context = array())
	{
		if (array_key_exists($event, static::$registered_events)) {
			array_map(function($handler) use ($context)
			{
				call_user_func($handler, $context);
			}, static::$registered_events[$event]);
		}
	}
1104629
private static function onReceivedMessage(string $event, $data)
    {
        foreach (self::$onMessage[$event] ?? [] as $callback) {
            asyncCall($callback, $data);
        }
    }
1325022
public static function trigger($event, $params=array())
	{
		if (isset(self::$events[$event]))
		{
			foreach (self::$events[$event] as $item)
			{
				if(true === call_user_func($item,$params))
				{
					// 事件返回true时不继续执行其余事件
					return true;
				}
			}
			return false;
		}
		return true;
	}
674261
public function call(string $event, $data = null)
    {
        if (! $this->eventExists($event)) {
            return null;
        }

        // inject request param on connect event
        $isConnect = $event === static::EVENT_CONNECT;
        $dataKey = $isConnect ? 'request' : 'data';

        // dispatch request to pipeline if middleware are set
        if ($isConnect && count($this->middleware)) {
            $data = $this->setRequestThroughMiddleware($data);
        }

        return App::call($this->callbacks[$event], [
            'websocket' => $this,
            $dataKey => $data,
        ]);
    }
110392
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options) {
		$formField = $this->_config['formField'];
		$formFieldRepeat = $this->_config['formFieldRepeat'];
		$formFieldCurrent = $this->_config['formFieldCurrent'];

		if (!isset($options['fields']) && $this->_config['forceFieldList']) {
			$options['fields'] = array_keys((array)$data);
		}
		if (isset($options['fields'])) {
			if (!in_array($formField, $options['fields'])) {
				$options['fields'][] = $formField;
			}
			if (!in_array($formFieldRepeat, $options['fields'])) {
				$options['fields'][] = $formFieldRepeat;
			}
			if (!in_array($formFieldCurrent, $options['fields'])) {
				$options['fields'][] = $formFieldCurrent;
			}
		}

		// Make sure fields are set and validation rules are triggered - prevents tempering of form data
		if (!isset($data[$formField])) {
			$data[$formField] = '';
		}
		if ($this->_config['confirm'] && !isset($data[$formFieldRepeat])) {
			$data[$formFieldRepeat] = '';
		}
		if ($this->_config['current'] && !isset($data[$formFieldCurrent])) {
			$data[$formFieldCurrent] = '';
		}

		// Check if we need to trigger any validation rules
		if (!$this->_config['require']) {
			$new = !empty($data[$formField]) || !empty($data[$formFieldRepeat]);

			// Make sure we trigger validation if allowEmpty is set but we have the password field set
			if ($new) {
				if ($this->_config['confirm'] && empty($data[$formFieldRepeat])) {
					//$entity->errors($formFieldRepeat, __d('tools', 'valErrPwdNotMatch'));
				}
			}
		}
	}
1198908
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);
	}
1161038
public function fire($event, &$client, $data = null)
    {
        $retval = true;

        if (!array_key_exists($event, $this->events)) {
            return;
        }

        foreach ($this->events[$event] as $callback) {
            if (!is_callable($callback)) {
                continue;
            }

            if (($retval = call_user_func($callback, $this, $client, $data)) === false) {
                break;
            }
        }

        return $retval !== false;
    }