From 7332d2c8ecee0282383bb188256aaf9a024c7ddd Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon Date: Fri, 15 Nov 2024 13:44:35 +0100 Subject: [PATCH] RedundancyGroupListItem: Apply restrictions to summary query - Add type hint for $state with @property tag instead --- .../Widget/ItemList/RedundancyGroupListItem.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php index 88aa1108d..9780053e2 100644 --- a/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php +++ b/library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php @@ -4,6 +4,7 @@ namespace Icinga\Module\Icingadb\Widget\ItemList; +use Icinga\Module\Icingadb\Common\Auth; use Icinga\Module\Icingadb\Common\Database; use Icinga\Module\Icingadb\Common\ListItemCommonLayout; use Icinga\Module\Icingadb\Model\RedundancyGroup; @@ -23,17 +24,16 @@ * Redundancy group list item. Represents one database row. * * @property RedundancyGroup $item + * @property RedundancyGroupState $state */ class RedundancyGroupListItem extends StateListItem { use ListItemCommonLayout; use Database; + use Auth; protected $defaultAttributes = ['class' => ['redundancy-group-list-item']]; - /** @var RedundancyGroupState */ - protected $state; - protected function init(): void { parent::init(); @@ -68,11 +68,12 @@ protected function assembleVisual(BaseHtmlElement $visual): void protected function assembleCaption(BaseHtmlElement $caption): void { - $caption->addHtml(new DependencyNodeStatistics( - RedundancyGroupSummary::on($this->getDb()) - ->filter(Filter::equal('id', $this->item->id)) - ->first() - )); + $summary = RedundancyGroupSummary::on($this->getDb()) + ->filter(Filter::equal('id', $this->item->id)); + + $this->applyRestrictions($summary); + + $caption->addHtml(new DependencyNodeStatistics($summary->first())); } protected function assembleTitle(BaseHtmlElement $title): void