Skip to content

Commit

Permalink
RedundancyGroupListItem: Apply restrictions to summary query
Browse files Browse the repository at this point in the history
- Add type hint for $state with @Property tag instead
  • Loading branch information
sukhwinder33445 committed Nov 15, 2024
1 parent 89c2405 commit 7332d2c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions library/Icingadb/Widget/ItemList/RedundancyGroupListItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7332d2c

Please sign in to comment.