summaryrefslogtreecommitdiffstats
path: root/application/forms/Command/Object/DeleteCommentForm.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/forms/Command/Object/DeleteCommentForm.php')
-rw-r--r--application/forms/Command/Object/DeleteCommentForm.php17
1 files changed, 8 insertions, 9 deletions
diff --git a/application/forms/Command/Object/DeleteCommentForm.php b/application/forms/Command/Object/DeleteCommentForm.php
index 25275ba..a35fc2e 100644
--- a/application/forms/Command/Object/DeleteCommentForm.php
+++ b/application/forms/Command/Object/DeleteCommentForm.php
@@ -4,12 +4,14 @@
namespace Icinga\Module\Icingadb\Forms\Command\Object;
-use Generator;
+use CallbackFilterIterator;
use Icinga\Module\Icingadb\Command\Object\DeleteCommentCommand;
use Icinga\Module\Icingadb\Forms\Command\CommandForm;
use Icinga\Web\Notification;
+use ipl\Orm\Model;
use ipl\Web\Common\RedirectOption;
use ipl\Web\Widget\Icon;
+use Iterator;
use Traversable;
class DeleteCommentForm extends CommandForm
@@ -54,16 +56,13 @@ class DeleteCommentForm extends CommandForm
);
}
- 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/comment/delete', $object->{$object->object_type})) {
- yield $object;
- }
- }
- })();
+ $granted = new CallbackFilterIterator($objects, function (Model $object): bool {
+ return $this->isGrantedOn('icingadb/command/comment/delete', $object->{$object->object_type});
+ });
+ $granted->rewind(); // Forwards the pointer to the first element
if ($granted->valid()) {
$command = new DeleteCommentCommand();
$command->setObjects($granted);