@param string $name
@param string $event

@return void
421484
protected function eventsCallback(string $name, string $event): void
    {
        $this->server->on($name, function () use ($name, $event) {
            try {
                $this->eventObjects[$name] = new $event(...$this->filterServer(func_get_args()));
                $this->eventObjects[$name]->handle($this);
            } catch (\Exception $e) {
                $this->app->make(ExceptionHandler::class)->report($e);
            } catch (\Throwable $e) {
                $this->app->make(ExceptionHandler::class)->report(new FatalThrowableError($e));
            }
        });
    }
213519
public function beginForm(string $name, string $action): void
    {
        $this->formOptions = $this->getFormOptions($name);

        $form = "<form id=\"{$name}\" action=\"{$action}\" method=\"post\"";

        $usePjax = (isset($this->formOptions['use_pjax'])) ?
            filter_var($this->formOptions['use_pjax'], FILTER_VALIDATE_BOOLEAN)
            : true;

        $pjaxAttr = ($usePjax) ? 'data-pjax' : '';

        foreach ($this->formOptions as $attr => $value) {
            if (in_array($attr, ['use_pjax', 'use_csrf', 'fields'])) {
                continue;
            }

            $form .= " {$attr}=\"{$value}\"";
        }

        echo "$form $pjaxAttr>";
    }
177871
public function serializeEvent($name, Event $event)
    {
        $context = SerializationContext::create();

        return serialize(array(
            'name' => $name,
            'class' => get_class($event),
            'event' => $this->serializer->serialize($event, 'json', $context),
        ));
    }
293183
public function help($event_name, $callback)
    {
        if (!isset($this->event_helpers[$event_name]))
        {
            $this->event_helpers[$event_name] = $callback;
        }
    }
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);
	}
142781
public function buildValidator(Event $event, Validator $validator, string $name): void
    {
        $this->validationStrictPassword($validator);
    }
1002317
protected function fireFinalEvent($name = null, $resource = null)
    {
        if (empty($name)) {
            $name = $this->getEventName();
        }
        if (empty($resource)) {
            $resource = $this->getEventResource();
        }
        /** @noinspection PhpUnusedLocalVariableInspection */
        $results = \Event::fire(new ApiEvent($name, $this->request, $this->response, $resource));
    }
634995
public function on(string $event, \Closure $closure): void
    {
        $this->events[$event] = $closure;
    }
561866
public function hasEventHandlers($name)
    {
        $this->ensureBehaviors();
        return !empty($this->__events__[$name]) || Event::hasHandlers($this, $name);
    }
634022
public function handle( IEvent $event, $name, IDispatcher $dispatcher )
    {
        $sections = explode( '\\', get_class( $event ) );
        $class    = $sections[ count( $sections ) - 1 ];

        $name = strtolower( substr( $class, 0, 1 ) ) . substr( $class, 1 ) . 'Handler';

        $this->{$name}( $event );
    }
357568
public function clickListElement(string $name): void
    {
        $this->context->getElementByText($name, $this->fields['listElement'])->click();
    }
868325
public function raiseEvent($name, $event)
    {
        $list = $this->getEventHandlers($name);
        foreach ($list as $handler) {
            if (is_string($name)) {
                call_user_func($handler, $event);
            } else if (is_callable($handler, true)) {
                if (is_array($handler)) {
                    // [object, methodName]
                    list($object, $method) = $handler;
                    if (is_string($object)) {
                        // 静态方法调用
                        call_user_func($handler, $event);
                    } else if (method_exists($object, $method)) {
                        // 实例方法
                        $object->$method($event);
                    } else {
                        throw new Exception(str_cover('事件"{class}.{event}"包含了无效的事件句柄"{handler}"', [
                            '{class}' => get_class($this),
                            '{event}' => $name,
                            '{handler}' => $handler[1],
                        ]), 100100207);
                    }
                } else {
                    // PHP 5.3: anonymous function
                    call_user_func($handler, $event);
                }
            }
        }
    }
752698
public function evaluateAttributes($event)
    {
        if (in_array($event->name, $this->events())) {
            foreach ($this->attributes as $attribute) {
                $this->owner->$attribute = $this->getValue($this->owner->$attribute, $event->name);
            }
        }
    }
793454
public static function clear(string $event = '') {
		if (empty($event)) {
			self::$events = [];
		} else {
			self::$events[$event] = [];
		}
	}
955190
protected function execute($event)
    {
        foreach($this->events[$event] as $handler) {
            $this->listen($event, $handler);
        }
    }
676592
public function delete($name)
	{
		$templates = $this->getTemplates();
		$templates->delete($name, $this->plugin->name);
	}
1338879
public function onInitDescription($event)
    {
        $sender = $event->sender;
        /* @var $sender static */
        if (!is_string($sender->descriptionAttribute) || empty($sender->descriptionAttribute)) {
            return;
        }
        $descriptionAttribute = $sender->descriptionAttribute;
        if (empty($sender->$descriptionAttribute)) {
            $sender->$descriptionAttribute = $sender->initDescription;
        }
    }