From 4b53bbff1554d65ddff52f5daaeaefbc1162ab71 Mon Sep 17 00:00:00 2001 From: Philipp Reisigl Date: Thu, 8 May 2025 16:40:36 +0200 Subject: [PATCH 1/7] View: remove code executing setModel() if $this->model exists --- src/View.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/View.php b/src/View.php index f2affaaa06..eb358dfabd 100644 --- a/src/View.php +++ b/src/View.php @@ -183,11 +183,6 @@ protected function init(): void foreach ($addLater as [$object, $region]) { $this->add($object, $region); } - - // allow for injecting the model with a seed - if (property_exists($this, 'model') && $this->model !== null) { - $this->setModel($this->model); // @phpstan-ignore method.notFound - } } public function getExecutorFactory(): ExecutorFactory From 944899095fa752c82cefe2e12a431b32b46d11f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Sun, 11 May 2025 14:00:54 +0200 Subject: [PATCH 2/7] Revert "View: remove code executing setModel() if $this->model exists" --- src/View.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/View.php b/src/View.php index eb358dfabd..f2affaaa06 100644 --- a/src/View.php +++ b/src/View.php @@ -183,6 +183,11 @@ protected function init(): void foreach ($addLater as [$object, $region]) { $this->add($object, $region); } + + // allow for injecting the model with a seed + if (property_exists($this, 'model') && $this->model !== null) { + $this->setModel($this->model); // @phpstan-ignore method.notFound + } } public function getExecutorFactory(): ExecutorFactory From 08bfb917082c2a2c49ac73496c90a35c8691c008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 May 2025 17:12:12 +0200 Subject: [PATCH 3/7] add to trait --- src/View/EntityTrait.php | 10 ++++++++++ src/View/ModelTrait.php | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/View/EntityTrait.php b/src/View/EntityTrait.php index 6a7b71c2fb..0548ca45ad 100644 --- a/src/View/EntityTrait.php +++ b/src/View/EntityTrait.php @@ -11,6 +11,16 @@ trait EntityTrait { public ?Model $entity = null; + #[\Override] + protected function init(): void + { + parent::init(); + + if ($this->entity !== null) { + $this->setEntity($this->entity); + } + } + /** * Associate this view with an entity. Do not place any logic in this method, instead take it to renderView(). * diff --git a/src/View/ModelTrait.php b/src/View/ModelTrait.php index 628f2fc0ff..301f24b29e 100644 --- a/src/View/ModelTrait.php +++ b/src/View/ModelTrait.php @@ -12,6 +12,16 @@ trait ModelTrait { public ?Model $model = null; + #[\Override] + protected function init(): void + { + parent::init(); + + if ($this->model !== null) { + $this->setModel($this->model); + } + } + /** * Associate this view with a model. Do not place any logic in this method, instead take it to renderView(). * From 8a891aa826115df4f8bfe796b4727d9541e3d9ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 May 2025 17:17:56 +0200 Subject: [PATCH 4/7] Revert "add to trait" --- src/View/EntityTrait.php | 10 ---------- src/View/ModelTrait.php | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/src/View/EntityTrait.php b/src/View/EntityTrait.php index 0548ca45ad..6a7b71c2fb 100644 --- a/src/View/EntityTrait.php +++ b/src/View/EntityTrait.php @@ -11,16 +11,6 @@ trait EntityTrait { public ?Model $entity = null; - #[\Override] - protected function init(): void - { - parent::init(); - - if ($this->entity !== null) { - $this->setEntity($this->entity); - } - } - /** * Associate this view with an entity. Do not place any logic in this method, instead take it to renderView(). * diff --git a/src/View/ModelTrait.php b/src/View/ModelTrait.php index 301f24b29e..628f2fc0ff 100644 --- a/src/View/ModelTrait.php +++ b/src/View/ModelTrait.php @@ -12,16 +12,6 @@ trait ModelTrait { public ?Model $model = null; - #[\Override] - protected function init(): void - { - parent::init(); - - if ($this->model !== null) { - $this->setModel($this->model); - } - } - /** * Associate this view with a model. Do not place any logic in this method, instead take it to renderView(). * From 983e6ad36950880c8c1bf5a891dbaed2b5be34d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 12 May 2025 17:23:38 +0200 Subject: [PATCH 5/7] improve comment --- src/View.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/View.php b/src/View.php index f2affaaa06..4978d22a7d 100644 --- a/src/View.php +++ b/src/View.php @@ -184,7 +184,7 @@ protected function init(): void $this->add($object, $region); } - // allow for injecting the model with a seed + // allow for injecting the model using View\ModelTrait if (property_exists($this, 'model') && $this->model !== null) { $this->setModel($this->model); // @phpstan-ignore method.notFound } From d10e0ae819c3458384043c80ebdd767bd1fe969c Mon Sep 17 00:00:00 2001 From: PhilippReisigl Date: Thu, 30 Apr 2026 09:05:32 +0200 Subject: [PATCH 6/7] add colspan to tEmpty before rendering it --- src/Table.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Table.php b/src/Table.php index 9e7ff5e4b0..c8f69130f9 100644 --- a/src/Table.php +++ b/src/Table.php @@ -427,6 +427,7 @@ protected function renderView(): void // add totals rows or empty message if ($this->_renderedRowsCount === 0) { if (!$this->jsPaginator || !$this->jsPaginator->getPage()) { + $this->tEmpty->set('columns', (string)count($this->columns)); $this->template->dangerouslyAppendHtml('Body', $this->tEmpty->renderToHtml()); } } elseif ($this->totalsPlan) { From d979890e1456455865a193983f9c636c577431b9 Mon Sep 17 00:00:00 2001 From: PhilippReisigl Date: Thu, 30 Apr 2026 09:14:27 +0200 Subject: [PATCH 7/7] make CS fixer happy --- src/Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Table.php b/src/Table.php index c8f69130f9..76251f2545 100644 --- a/src/Table.php +++ b/src/Table.php @@ -427,7 +427,7 @@ protected function renderView(): void // add totals rows or empty message if ($this->_renderedRowsCount === 0) { if (!$this->jsPaginator || !$this->jsPaginator->getPage()) { - $this->tEmpty->set('columns', (string)count($this->columns)); + $this->tEmpty->set('columns', (string) count($this->columns)); $this->template->dangerouslyAppendHtml('Body', $this->tEmpty->renderToHtml()); } } elseif ($this->totalsPlan) {