From 8740f6b6c85591f92d41911d2867ee7996c8acdb Mon Sep 17 00:00:00 2001 From: flack Date: Wed, 17 Jan 2024 17:09:09 +0100 Subject: [PATCH] Small simplifications --- src/midcom/httpkernel/subscriber.php | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/midcom/httpkernel/subscriber.php b/src/midcom/httpkernel/subscriber.php index b3acb8690..47d10e48f 100644 --- a/src/midcom/httpkernel/subscriber.php +++ b/src/midcom/httpkernel/subscriber.php @@ -29,8 +29,6 @@ */ class subscriber implements EventSubscriberInterface { - private bool $initialized = false; - public static function getSubscribedEvents() { return [ @@ -52,12 +50,10 @@ private function initialize(Request $request) return $response; } - // This checks for the unittest case - if (!$request->attributes->has('context')) { - // Initialize Context Storage - $context = midcom_core_context::enter(midcom_connection::get_url('uri')); - $request->attributes->set('context', $context); - } + // Initialize Context Storage + $context = midcom_core_context::enter(midcom_connection::get_url('uri')); + $request->attributes->set('context', $context); + // Initialize the UI message stack from session $midcom->uimessages->initialize($request); @@ -68,16 +64,13 @@ private function initialize(Request $request) public function on_request(RequestEvent $event) { $request = $event->getRequest(); - if (!$this->initialized) { - $this->initialized = true; - if ($response = $this->initialize($request)) { - $event->setResponse($response); - return; - } + if ( $event->isMainRequest() + && $response = $this->initialize($request)) { + $event->setResponse($response); + return; } $resolver = new resolver($request); - if ($resolver->process_midcom()) { return; }