From ad1092f659d3a148cc20a25eb63beda8fb246c8f Mon Sep 17 00:00:00 2001 From: Ingolf Steinhardt Date: Wed, 25 Sep 2024 18:34:05 +0200 Subject: [PATCH] Fix runtime exception at filter collection --- .../Resources/config/dc-general/table/tl_dcasetting.yml | 1 + .../dc-general/table/tl_metamodel_rendersetting.yml | 1 + src/Filter/Setting/Collection.php | 8 ++++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/CoreBundle/Resources/config/dc-general/table/tl_dcasetting.yml b/src/CoreBundle/Resources/config/dc-general/table/tl_dcasetting.yml index c31924af2..49fa07b1b 100644 --- a/src/CoreBundle/Resources/config/dc-general/table/tl_dcasetting.yml +++ b/src/CoreBundle/Resources/config/dc-general/table/tl_dcasetting.yml @@ -5,6 +5,7 @@ services: - "@database_connection" - "@metamodels.factory" - "@router" + - "@request_stack" tags: - name: kernel.event_listener event: dc-general.view.contao2backend.get-global-button diff --git a/src/CoreBundle/Resources/config/dc-general/table/tl_metamodel_rendersetting.yml b/src/CoreBundle/Resources/config/dc-general/table/tl_metamodel_rendersetting.yml index df707a8e2..bb6cf37e5 100644 --- a/src/CoreBundle/Resources/config/dc-general/table/tl_metamodel_rendersetting.yml +++ b/src/CoreBundle/Resources/config/dc-general/table/tl_metamodel_rendersetting.yml @@ -5,6 +5,7 @@ services: - "@database_connection" - "@metamodels.factory" - "@router" + - "@request_stack" tags: - name: kernel.event_listener event: dc-general.view.contao2backend.get-global-button diff --git a/src/Filter/Setting/Collection.php b/src/Filter/Setting/Collection.php index 095cb3d53..48cd63249 100644 --- a/src/Filter/Setting/Collection.php +++ b/src/Filter/Setting/Collection.php @@ -55,9 +55,9 @@ class Collection implements ICollection /** * The attached MetaModel. * - * @var IMetaModel + * @var IMetaModel|null */ - protected $metaModel; + protected $metaModel = null; /** * Create a new instance. @@ -100,6 +100,10 @@ public function setMetaModel($metaModel): self */ public function getMetaModel() { + if (null === $this->metaModel) { + throw new \RuntimeException('Meta model not set'); + } + return $this->metaModel; }