src/Valkyrja/Events/NativeEvents.php
public function setup(bool $force = false, bool $useCache = true): void
    {
        if (self::$setup && ! $force) {
            return;
        }

        self::$setup = true;

        // If the application should use the events cache files
        if ($useCache && $this->app->config()['events']['useCache']) {
            $this->setupFromCache();

            // Then return out of setup
            return;
        }

        self::$events = [];

        // If annotations are enabled and the events should use annotations
        if (
            $this->app->config()['events']['useAnnotations']
            && $this->app->config()['annotations']['enabled']
        ) {
            // Setup annotated event listeners
            $this->setupAnnotations();

            // If only annotations should be used
            if ($this->app->config()['events']['useAnnotationsExclusively']) {
                // Return to avoid loading events file
                return;
            }
        }

        // Include the events file
        require $this->app->config()['events']['filePath'];
    }
public function setup(bool $force = false, bool $useCache = true): void
    {
        if (self::$setup && ! $force) {
            return;
        }

        self::$setup = true;

        // If the application should use the events cache files
        if ($useCache && $this->app->config()['events']['useCache']) {
            $this->setupFromCache();

            // Then return out of setup
            return;
        }

        self::$events = [];

        // If annotations are enabled and the events should use annotations
        if (
            $this->app->config()['events']['useAnnotations']
            && $this->app->config()['annotations']['enabled']
        ) {
            // Setup annotated event listeners
            $this->setupAnnotations();

            // If only annotations should be used
            if ($this->app->config()['events']['useAnnotationsExclusively']) {
                // Return to avoid loading events file
                return;
            }
        }

        // Include the events file
        require $this->app->config()['events']['filePath'];
    }
Setup the events.

@param bool $force    [optional] Whether to force setup
@param bool $useCache [optional] Whether to use cache

@throws \Valkyrja\Dispatcher\Exceptions\InvalidClosureException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidDispatchCapabilityException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidFunctionException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidMethodException
@throws \Valkyrja\Dispatcher\Exceptions\InvalidPropertyException

@return void