Trigger a grouped event

@param mixed ?array
@param mixed ?array
@return void
499237
public function triggerGroup(?array $events = [], ?array $args = null)
  {
    foreach($events as $callback) {
      if (is_callable($callback)) {
        call_user_func_array($callback, isset($args) ? $args : []);
      }
      else if (is_string($callback)) {
        $call = new $callback;
        call_user_func_array([$call, 'persist'], $args ?? []);
      }
    }
  }
604680
public function triggerEvent(string $event): void
    {
        // TODO: use event library and allow attach events to IFile and ICacheStateful.
        // cache triggers
        if ($this->file instanceof ICacheStateful) {
            switch ($event) {
                case self::EVENT_CACHED:
                    $this->file->setCachedAt($this->name, time());
                    break;
                case self::EVENT_EMPTY:
                case self::EVENT_ERROR:
                case self::EVENT_NOT_FOUND:
                    // TODO: split those and save different cases of cache state.
                    $this->file->setCachedAt($this->name, null);
                    break;
            }

            $this->file->saveState();
        }

        // other triggers
    }
64601
public function initEvents()
    {
        foreach (array('onShow', 'onShown') as $event) {
            if ($this->$event !== null) {
                $modalEvent = strtolower(substr($event, 2));
                if ($this->$event instanceof CJavaScriptExpression) {
                    $this->events[$modalEvent] = $this->$event;
                } else {
                    $this->events[$modalEvent] = new CJavaScriptExpression($this->$event);
                }
            }
        }
    }
1134043
function (/* items... */) {
		var items = slice(arguments);
		var item;
		for (var i = 0, l = items.length; i < l; i++) {
			item = items[i];
			$Array.push.call(this, item);
			this.trigger(EVENT_ADD, item, this.length);
		}
		return this.length;
	}
133105
public function trigger($event, $data = null)
    {
        return $this->events->trigger($event, $this, $data);
    }
254644
private function applySelect() : void
    {
        $group = $this->query->clause('group');
        $group = array_filter($group);
        if (empty($group)) {
            return;
        }

        $this->query->select($group, true);
        $this->query->select([self::GROUP_BY_FIELD => $this->query->func()->count($group[0])]);
    }
56076
public function addGrouping( $grouping )
	{
		if( is_array( $grouping ) )
			return $this->addGroupings( $grouping );
		if( in_array( $grouping, $this->groupings ) )
			return FALSE;
		$this->groupings[] = $grouping;
		return TRUE;
	}
191471
function startGroup(&$group, $required, $error) 
    {
        $this->_currentGroup = $this->_elementToObject($group, $required, $error);
        if(!empty($error)) {
            $name = $this->_currentGroup->name;
            $this->_obj->errors->$name = $error;
        }
    }
1074090
function trigger (el, event) {
  if (document.createEvent) {
    var ev = document.createEvent('HTMLEvents')
    ev.initEvent(event, true, false)
    el.dispatchEvent(ev)
  } else {
    el.fireEvent('on' + event)
  }
}
88195
public function addContextEvent($event = [])
    {
        $contactId                       = isset($this->context['id']) ? $this->context['id'] : 0;
        $this->context['event']['id']    = !empty($event['id']) ? (int) $event['id'] : null;
        $this->context['event']['name']  = !empty($event['name']) ? $event['name'] : null;
        $this->context['event']['token'] = null;
        if ($contactId || $this->context['event']['id'] || $this->context['campaign']['id']) {
            $this->context['event']['token'] = $this->eventTokenEncode(
                [
                    $this->context['campaign']['id'],
                    $this->context['event']['id'],
                    $contactId,
                ]
            );
        }
    }
553235
protected function ensureEvents()
	{
		if ($this->_events === null) {
			$this->_events = [];
			if (method_exists($this, 'events')) {
			    if ($events = $this->events()) foreach ($events as $name => $handler) {
					$this->on($name, $handler);
				}
			}
		}
	}
579526
function onQuickFormEvent($event, $arg, &$caller)
    {
        switch ($event) {
            case 'createElement':
                static::__construct($arg[0], $arg[1], $arg[2]);
                $caller->_registerCancelButton($this->getName());
                return true;
                break;
        }
        return parent::onQuickFormEvent($event, $arg, $caller);
    }
1030604
function set_group($group_id)
    {
        if ($group_id) {
            $this->group_id = $group_id;
            $this->group_data = $this->get_group_entry($group_id);
        }
        else {
            $this->group_id = 0;
            $this->group_data = null;
        }
    }
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);
            }
        });
        
    }
471151
function notify(\pq\Gateway\Row $row = null, $event = null, array &$where = null) {
		foreach ($this->observers as $observer) {
			$observer->update($this, $row, $event, $where);
		}
	}
527627
public function eventBeforeInsert()
    {
        $item = self::find()->where([
            'nav_container_id' => $this->nav_container_id,
            'parent_nav_id' => $this->parent_nav_id
        ])->orderBy('sort_index DESC')->limit(1)->asArray()->one();
        if (!$item) {
            $this->sort_index = 1;
        } else {
            $this->sort_index = $item['sort_index'] + 1;
        }
    }
844420
protected function trigger($event, &$params)
    {
        if (isset(self::$event[$this->class][$event])) {
            foreach (self::$event[$this->class][$event] as $callback) {
                if (is_callable($callback)) {
                    $result = call_user_func_array($callback, [ & $params]);
                    if (false === $result) {
                        return false;
                    }
                }
            }
        }
        return true;
    }