Register the event callback.
7200
protected function registerWorkerErrorCallback()
    {
        $this->swooleServer->on('WorkerError', function ($server, $workerId, $workerPid, $exitCode, $signal) {
            $this->reportWorkerError($workerId, $workerPid, $exitCode, $signal);

            $this->events->dispatch(new Events\WorkerError($this, $workerId, $workerPid, $exitCode, $signal));

            $this->dispatchEvent('WorkerError', $this, $workerId, $workerPid, $exitCode, $signal);
        });
    }
1237412
protected function registerCloseCallback()
    {
        $this->swooleServer->on('Close', function ($server, $fd, $reactorId) {
            $this->dispatchEvent('Close', $this, $fd, $reactorId);
        });
    }
1148899
def trigger(self, event: str, *args: T.Any, **kw: T.Any) -> bool:
        """"""

        callbacks = list(self._events.get(event, []))
        if not callbacks:
            return False

        for callback in callbacks:
            callback(*args, **kw)
        return True
1180721
public function register($event, $callback)
	{
		// check if this is a valid event type
		if ( ! isset($this->callbacks[$event]))
		{
			throw new \InvalidArgumentException($event.' is not a valid event');
		}

		// check if the callback is acually callable
		if ( ! is_callable($callback))
		{
			throw new \InvalidArgumentException('Callback passed is not callable');
		}

		// store it
		$this->callbacks[$event][] = $callback;
	}
1294099
private function register_event_listener() {

		$cron_array = _get_cron_array();
		if ( ! $cron_array ) {
			return;
		}

		$hooks = array_reduce(
			$cron_array,
			function ( $hooks, $crons ) {

				return array_merge( $hooks, array_keys( $crons ) );
			},
			[]
		);

		$profile_cb = function () {

			$this->cron_action_profile();
		};

		array_walk(
			$hooks,
			function ( $hook ) use ( $profile_cb ) {

				// Please note that "(int) ( PHP_INT_MAX + 1 )" is the lowest possible integer.
				add_action( $hook, $profile_cb, (int) ( PHP_INT_MAX + 1 ) );
				add_action( $hook, $profile_cb, PHP_INT_MAX );
			}
		);

		self::$ran = TRUE;
	}
781052
def register(self, event_type: str,
                 **data_detail: Any) -> Callable[[AsyncCallback], AsyncCallback]:
        """"""
        def decorator(func: AsyncCallback) -> AsyncCallback:
            self.add(func, event_type, **data_detail)
            return func
        return decorator
276758
static public function register($event, $method, $class = null)
    {
        if (!empty($class) && class_exists($class, false) && method_exists($class, $method)) {
            self::$callback[$event] = array($class, $method);
        } else {
            self::$callback[$event] = $method;
        }
    }
1335308
private function registerListeners(): void
    {
        Event::listen(ReactionHasBeenAdded::class, IncrementAggregates::class);
        Event::listen(ReactionHasBeenRemoved::class, DecrementAggregates::class);
    }
1267655
def enable_events(self, event_callback=None) -> None:
        """"""
        self.event = EventManager(event_callback)
        self.stream.event = self.event
865000
def register(self, event, callback):
        
        pattern = self.channels.event_pattern(event)
        entry = self.callbacks.get(pattern)
        if not entry:
            entry = event_callbacks(event, pattern, re.compile(pattern), [])
            self.callbacks[entry.pattern] = entry

        if callback not in entry.callbacks:
            entry.callbacks.append(callback)

        return entry
785782
protected function registerReceiveCallback()
    {
        $this->swoolePort->on('Receive', function ($server, $fd, $reactorId, $data) {
            $this->dispatchEvent('Receive', $this->server, $this, $fd, $reactorId, $data);
        });
    }
576032
def register_event(self, event_name, event_level, message):
        
        self.events[event_name] = (event_level, message)
975539
public static function register()
	{
		$class = new self();
		Events::addListener(array($class, 'screenLogEventListener'), 'screenLogEvent', EventPriority::NORMAL);
		$bar = Debugger::getBar();
		$bar->addPanel($class);
	}
443704
def register_callbacks(self, on_create, on_modify, on_delete):
        
        self.on_create = on_create
        self.on_modify = on_modify
        self.on_delete = on_delete
517913
public static function register($event, $callback, $first=false)
	{
		if (! isset(self::$events[$event]))
		{
			self::$events[$event] = array ();
		}
		if($first)
		{
			array_unshift(self::$events[$event],$callback);
		}
		else 
		{
			self::$events[$event][] = $callback;
		}
	}
64503
public function registerPortEvents(): void
    {
        foreach ((array)$this->options['events'] as $event => $method) {
            // ['onConnect'] --> 'Connect', 'onConnect
            if (\is_int($event)) {
                $event = substr($method, 2);
            }

            // e.g $server->on('Request', [$this, 'onRequest']);
            if (method_exists($this, $method)) {
                $this->port->on($event, [$this, $method]);
            }
        }
    }
477946
def is_registered(self, event: str, handler: T.Callable) -> bool:
        """"""

        return handler in self._events.get(event, [])