We will activate middle ware events if set as true in
src/Apps/Configs/application.php.

@return mixed
350056
public function activateEventMiddleWare()
    {
        $isEventActive = $this->isEventMiddlewareEnabled();
        $eventClass = Config::get('global.config', 'app.event.class');

        if ($isEventActive && !$this->container->has('event')) {
            $this->container->set('event', $this->container->make($eventClass));
            $this->container->get('event')->register($this->container);

            return true;
        }

        return false;
    }
293625
public static function manifestEvent()
    {
        $args     = func_get_args();
        $callback = array_shift($args);

        if (Arr::key($callback, self::$_eventList)) {
            $callbacks = self::$_eventList[$callback];
            foreach ($callbacks as $method) {
                call_user_func_array($method, $args);
            }
        }
    }
649586
public function activateAction()
    {
        $object = $this->getObject();
        
        if (method_exists($object, 'setActive') && method_exists($object, 'getActive')) {
            $object->setActive(($object->getActive()==1) ? 0 : 1);
        }
        
        $this->admin->update($object);        
        
        return new RedirectResponse($this->admin->generateUrl('list'));
    }
1171999
public function activate()
    {
        $this->activated_at = date('Y-m-d H:i:s');
        $this->active = true;

        EventManager::instance()->dispatch(new Event('Wasabi.User.activated', $this));

        return $this;
    }
794754
private function _getEventsConfig()
    {
        $content = array(self:: MAIN_EVENTS_FILE => array());

        $configPath = $this->_configPath;
        if (! is_dir($configPath)) {
            return $content;
        }

        $files = DirData::listFilesRecursive($configPath, self:: MAIN_EVENTS_FILE . self::EXT);
        foreach ($files as $file) {
            $content[self:: MAIN_EVENTS_FILE] = array_merge_recursive(require($file), $content[self:: MAIN_EVENTS_FILE]);
        }

        return $content;
    }
321829
public function actionStop()
    {
        $message = 'Stopping Yii 2 Daemon ' . $this->version . '... ';
        $result = static::EXIT_CODE_NORMAL;
        if ($this->_getPid() !== false) {
            $this->_killPid();
            $message .= 'OK.';
        } else {
            $message .= 'Service is not running!';
            $result = static::EXIT_CODE_ERROR;
        }
        echo $message . PHP_EOL;
        $this->_log($message);
        return $result;
    }
1368203
public function remove()
    {
        if($moduleMiddleware = $this->module->middleware())
        {
            $middleware = $this->load();
            $middleware = array_diff($middleware,$moduleMiddleware);
            return $this->set($middleware);
        }
        return true;
    }
1035167
private static function runAppMiddleware()
    {
        $appMiddleware = Filter::$middleware;

        foreach ($appMiddleware as $middleware) {
            $middleware = instance($middleware);

            $middleware->handle(new Request());
        }

        return true;
    }
235354
public function getEvent()
    {
        if (null === $this->event) {
            $event = new AuthenticationEvent();

            $this->setEvent($event);
        }

        return $this->event;
    }
554281
protected static function middleware()
    {
        foreach (self::fetch('http/middleware') as $file) {
            Bus::need($file);
        }

        Middleware::ini();
    }
757453
public function run()
    {
        $event = $this->getMvcEvent();

        // Define callback used to determine whether or not to short-circuit
        $shortCircuit = function ($r) use ($event) {
            if ($r instanceof Response) {
                return true;
            }
            return false;
        };

        $events = $this->getEventManager();
        $result = $events->trigger(MvcEvent::EVENT_DISPATCH, $event, $shortCircuit);

        // Complete response
        $response = $result->last();
        if ($response instanceof Response) {
            $event->setTarget($this);
            $events->trigger(MvcEvent::EVENT_FINISH, $event);
        }

    }
459549
public function unRegisterMiddleware()
    {
        if (is_array($this->middleware()) && count($this->middleware()))
        {
            $middleware = new Middleware($this);
            return $middleware->remove();
        }
        return true;
    }
995750
private static function middleware()
    {
        $files = ['Filters', 'Middleware'];
        $folder = static::$root.'Http/Middleware'.'/';

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

        $files = ['MiddlewareNotFoundException', 'MiddlewareWallException'];
        $folder = static::$root.'Http/Middleware/Exceptions'.'/';

        self::call($files, $folder);
    }
1208721
public function activate()
    {
        // register hooks
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['isOutputting'][__CLASS__] = UserGroupDetector::class . '->disableFrontendOutput';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-PostProc'][__CLASS__] = UserGroupDetector::class . '->disableCaching';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'][__CLASS__] = UserGroupDetector::class . '->deactivateTcaFrontendGroupEnableFields';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['hook_checkEnableFields'][__CLASS__] = UserGroupDetector::class . '->checkEnableFields';

        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPage'][__CLASS__] = UserGroupDetector::class;
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_page.php']['getPageOverlay'][__CLASS__] = UserGroupDetector::class;

        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'][__CLASS__] = UserGroupDetector::class;
    }
192737
public function unRegisterEvents()
    {
        if (is_array($this->events()) && count($this->events()))
        {
            $event = new Event($this);
            return $event->remove();
        }
        return true;
    }
534751
public function getEvents()
    {
        if (! $this->events) {
            $services = $this->getServices();
            $events   = $services->get('Events');
            $this->setEvents($events);
        }

        return $this->events;
    }
1171616
public function onRun()
    {
        /*
         * Redirect to HTTPS checker
         */
        if ($redirect = $this->redirectForceSecure()) {
            return $redirect;
        }

        /*
         * Activation code supplied
         */
        if ($code = $this->activationCode()) {
            $this->onActivate($code);
        }

        $this->prepareVars();
    }