diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:45:00 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 11:45:00 +0000 |
commit | be4626482ba8761da39746a6ac60d133d3852a0f (patch) | |
tree | 45065832c85c4789237e94b3114360eac91d86f0 /application/forms/Command/Object/ScheduleCheckForm.php | |
parent | Releasing progress-linux version 1.1.1-1~progress7.99u1. (diff) | |
download | icingadb-web-be4626482ba8761da39746a6ac60d133d3852a0f.tar.xz icingadb-web-be4626482ba8761da39746a6ac60d133d3852a0f.zip |
Merging upstream version 1.1.2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'application/forms/Command/Object/ScheduleCheckForm.php')
-rw-r--r-- | application/forms/Command/Object/ScheduleCheckForm.php | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/application/forms/Command/Object/ScheduleCheckForm.php b/application/forms/Command/Object/ScheduleCheckForm.php index 9b32ea1..bdeba53 100644 --- a/application/forms/Command/Object/ScheduleCheckForm.php +++ b/application/forms/Command/Object/ScheduleCheckForm.php @@ -4,9 +4,9 @@ namespace Icinga\Module\Icingadb\Forms\Command\Object; +use CallbackFilterIterator; use DateInterval; use DateTime; -use Generator; use Icinga\Module\Icingadb\Command\Object\ScheduleCheckCommand; use Icinga\Module\Icingadb\Forms\Command\CommandForm; use Icinga\Module\Icingadb\Model\Host; @@ -14,8 +14,10 @@ use Icinga\Web\Notification; use ipl\Html\Attributes; use ipl\Html\HtmlElement; use ipl\Html\Text; +use ipl\Orm\Model; use ipl\Web\FormDecorator\IcingaFormDecorator; use ipl\Web\Widget\Icon; +use Iterator; use Traversable; use function ipl\Stdlib\iterable_value_first; @@ -109,22 +111,17 @@ class ScheduleCheckForm extends CommandForm (new IcingaFormDecorator())->decorate($this->getElement('btn_submit')); } - protected function getCommands(Traversable $objects): Traversable + protected function getCommands(Iterator $objects): Traversable { - $granted = (function () use ($objects): Generator { - foreach ($objects as $object) { - if ( - $this->isGrantedOn('icingadb/command/schedule-check', $object) - || ( - $object->active_checks_enabled - && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) - ) - ) { - yield $object; - } - } - })(); + $granted = new CallbackFilterIterator($objects, function (Model $object): bool { + return $this->isGrantedOn('icingadb/command/schedule-check', $object) + || ( + $object->active_checks_enabled + && $this->isGrantedOn('icingadb/command/schedule-check/active-only', $object) + ); + }); + $granted->rewind(); // Forwards the pointer to the first element if ($granted->valid()) { $command = new ScheduleCheckCommand(); $command->setObjects($granted); |