关注事件
@return array|void
489914
protected function matchEventSubscribe()
    {
        // 扫码关注
        if (array_key_exists('Eventkey', $this->message) && strexists($this->message['Eventkey'], 'qrscene')) {
            $this->message['Eventkey'] = explode('_', $this->message['Eventkey'])[1]; // 取二维码的参数值
            return $this->matchEventScan();
        }
        // 订阅请求回复规则触发
        return ReplyRuleKeyword::find()
            ->andFilterWhere(['type' => [ReplyRuleKeyword::TYPE_SUBSCRIBE]])
            ->wechatRule($this->getWechat()->id)
            ->limitTime(TIMESTAMP)
            ->all();
    }
951703
public function subscribeAuthEvents()
    {
        foreach (static::$authEventHandlerMap as $eventName => $handler) {
            $this->events->listen($eventName, [$this, $handler]);
        }
    }
917844
public function run()
	{
		$script = "jQuery('{$this->selector}').attr('data-spy', 'scroll');";

		if (isset($this->target)) {
			$script .= "jQuery('{$this->selector}').attr('data-target', '{$this->target}');";
		}

		if (isset($this->offset)) {
			$script .= "jQuery('{$this->selector}').attr('data-offset', '{$this->offset}');";
		}

		/** @var CClientScript $cs */
		$cs = Yii::app()->getClientScript();
		$cs->registerScript(__CLASS__ . '#' . $this->selector, $script, CClientScript::POS_BEGIN);

		foreach ($this->events as $name => $handler) {
			$handler = CJavaScript::encode($handler);
			$cs->registerScript(
				__CLASS__ . '#' . $this->selector . '_' . $name,
				"jQuery('{$this->selector}').on('{$name}', {$handler});"
			);
		}
	}
944176
public function execute()
    {
        $events = $this->eventQueue->getEvents($this->chunkSize);
        if (!empty($events)) {
            $this->eventIndex->indexEvents($events);
            $this->sessionIndex->indexEvents($events);
            $this->eventQueue->deleteEvents(array_column($events, 'event_id'));
        }
    }
851612
public function detectChanges()
    {
        clearstatcache(true, $this->path);

        if (! $this->exists && $this->files->exists($this->path)) {
            $this->lastModified = $this->files->lastModified($this->path);
            $this->exists = true;

            return [new Event($this, Event::RESOURCE_CREATED)];
        } elseif ($this->exists && ! $this->files->exists($this->path)) {
            $this->exists = false;

            return [new Event($this, Event::RESOURCE_DELETED)];
        } elseif ($this->exists && $this->isModified()) {
            $this->lastModified = $this->files->lastModified($this->path);

            return [new Event($this, Event::RESOURCE_MODIFIED)];
        }

        return [];
    }
437660
public function getEvents()
    {
        $events = [];

        $statement = $this->connection->prepare('SELECT * FROM ' . $this->table);

        $result = $statement->execute();

        if (0 < count($result)) {
            foreach ($result as $row) {
                var_dump($row);
                $events[] = (new Event())
                    ->setId($row['id']);
            }
        }

        return $events;
    }
659589
public function start() {
        if ($this->dialect) {
            //允许事务嵌套
            $this->transLevel += 1;
            $dialect          = $this->dialect;
            if ($dialect->inTransaction()) {
                return true;
            }
            $rst = $dialect->beginTransaction();
            if ($rst) {
                return true;
            } else {
                $this->transLevel -= 1;
            }
        }

        return false;
    }
310528
function () {
                var self = this, attrs = self.getAttrs(), attr, m;
                for (attr in attrs) {
                    m = ON_SET + ucfirst(attr);
                    if (self[m]) {
                        // 自动绑定事件到对应函数
                        self.on('after' + ucfirst(attr) + 'Change', onSetAttrChange);
                    }
                }
            }
424178
private function checkUser() {
        //事件监听守护进程的配置(跟事件及其监听器的配置是两码事)
        $config = $this->appContext->getConfig('eventListend') ?: [];
        $username = isset($config['user']) ? $config['user'] : 'nobody';
        $groupName = isset($config['group']) ? $config['group'] : 'nobody';

        $userInfo = posix_getpwnam($username);
        if (!$userInfo) {
            _throw("用户“{$username}”不存在，启动失败");
        }

        $groupInfo = posix_getgrnam($groupName);
        if (!$groupInfo) {
            _throw("用户组“{$groupName}”不存在，启动失败");
        }

        return [$userInfo, $groupInfo];
    }
254554
private static function event()
    {
        $files = ['Event', 'EventListener'];
        $folder = static::$root.'Event'.'/';

        self::call($files, $folder);

        $files = ['ManyListenersArgumentsException'];
        $folder = static::$root.'Event/Exceptions'.'/';

        self::call($files, $folder);
    }
229304
protected function __bindEvents()
    {
        $server = $this->swoolePort ?? $this->swooleServer;

        $server->on('packet', function(\swoole_server $server, $data, $clientInfo){
            try{
                $this->trigger('packet', [
                    'server'        => $this,
                    'data'          => $data,
                    'clientInfo'    => $clientInfo,
                ], $this, PacketEventParam::class);
            }
            catch(\Throwable $ex)
            {
                App::getBean('ErrorLog')->onException($ex);
            }
        });
        
    }
573633
public function getAllListeners() : array
    {
        foreach ($this->listeners as $event => $listeners) {
            if (! isset($this->sorted[$event])) {
                $this->sorted[$event] = $this->sortListeners($listeners);
            }
        }

        return $this->sorted;
    }
505386
public function actionEvents() {

		$user = Yii::$app->user->GetIdentity();

		$startDate	= Yii::$app->request->post( 'startDate' );
		$endDate	= Yii::$app->request->post( 'endDate' );

		$events = $this->modelService->getByRangeUserId( $startDate, $endDate, $user->id );
		$data	= [];

		foreach( $events as $event ) {

			$data[] = [ 'id' => $event->id, 'title' => "$event->name - $event->description", 'start' => $event->scheduledAt ];
		}

		// Trigger Ajax Success
		return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data );
	}
1374475
private function registerEvents()
    {
        foreach ($this->getSetting('events', []) as $event => $listeners) {
            foreach ($listeners as $listener) {
                Event::bind($event, $listener);
            }
        }
    }
61562
protected function flush() {
        global $DB;

        // Flush the buffer to the db.
        $events = $this->buffer;
        $DB->insert_records('tool_monitor_events', $events); // Insert the whole chunk into the database.
        $this->buffer = array();
        $this->count = 0;
        return $events;
    }
94596
protected function registerEventListeners()
    {
        foreach ($this->events as $event => $listener) {
            Event::listen($event, $listener);
        }

        return $this;
    }
1195781
public function init() {
		//触发应用开始事件
		$this->eventDispatcher->dispatchEvent(new \Fasim\Event\Event(\Fasim\Event\Event::$APP_START));

		//初始化配置
		$this->registerFacdes();

		//设置时区
		$timezone = $this->make('config')->get('timezone', 'Asia/Shanghai');
		date_default_timezone_set($timezone);

		//设置调试模式
		$debugMode = $this->make('config')->get('debug') === true;
		$this->setDebugMode($debugMode);
		$this->eventDispatcher->dispatchEvent(new \Fasim\Event\Event(\Fasim\Event\Event::$APP_READY));
	}