From fa91223f4e146cd491fe2b329e7f7bbf623f944d Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Mon, 9 Oct 2023 11:15:51 +0200 Subject: [PATCH 1/2] feat: helper function to rebuild and restart DI container in same request/process --- common/oatbox/service/ServiceManager.php | 8 ++++++++ scripts/tools/ContainerCacheWarmup.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/oatbox/service/ServiceManager.php b/common/oatbox/service/ServiceManager.php index ed35906e9..7e491c57d 100644 --- a/common/oatbox/service/ServiceManager.php +++ b/common/oatbox/service/ServiceManager.php @@ -265,6 +265,14 @@ public function getContainer(): ContainerInterface return $this->getContainerStarter()->getContainer(); } + public function rebuildContainer(): bool + { + $this->getContainerStarter()->getContainerBuilder()->forceBuild(); + $this->containerStarter = null; + + return true; + } + /** * @TODO ContainerBuilder will be removed from here as soon as we do not need ServiceManager anymore. */ diff --git a/scripts/tools/ContainerCacheWarmup.php b/scripts/tools/ContainerCacheWarmup.php index bf47021e0..39f451135 100644 --- a/scripts/tools/ContainerCacheWarmup.php +++ b/scripts/tools/ContainerCacheWarmup.php @@ -49,7 +49,7 @@ protected function provideDescription(): string protected function run(): Report { - $this->getServiceManager()->getContainerBuilder()->forceBuild(); + $this->getServiceManager()->rebuildContainer(); return Report::createSuccess('Dependency Injection Container cache warmed up!'); } From d7b2a73a7c3cc7a6a696ab8cc669885a3ecfe828 Mon Sep 17 00:00:00 2001 From: Augustas Nedzinskas Date: Mon, 9 Oct 2023 11:23:26 +0200 Subject: [PATCH 2/2] fix: rebuild returns nothing --- common/oatbox/service/ServiceManager.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/common/oatbox/service/ServiceManager.php b/common/oatbox/service/ServiceManager.php index 7e491c57d..5d3a414a4 100644 --- a/common/oatbox/service/ServiceManager.php +++ b/common/oatbox/service/ServiceManager.php @@ -265,12 +265,10 @@ public function getContainer(): ContainerInterface return $this->getContainerStarter()->getContainer(); } - public function rebuildContainer(): bool + public function rebuildContainer(): void { $this->getContainerStarter()->getContainerBuilder()->forceBuild(); $this->containerStarter = null; - - return true; } /**