summaryrefslogtreecommitdiffstats
path: root/application/forms/Command/Object/AddCommentForm.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/forms/Command/Object/AddCommentForm.php')
-rw-r--r--application/forms/Command/Object/AddCommentForm.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/application/forms/Command/Object/AddCommentForm.php b/application/forms/Command/Object/AddCommentForm.php
index 9cd0754..e991e84 100644
--- a/application/forms/Command/Object/AddCommentForm.php
+++ b/application/forms/Command/Object/AddCommentForm.php
@@ -4,6 +4,7 @@
namespace Icinga\Module\Icingadb\Forms\Command\Object;
+use CallbackFilterIterator;
use DateInterval;
use DateTime;
use Icinga\Application\Config;
@@ -14,9 +15,11 @@ use Icinga\Web\Notification;
use ipl\Html\Attributes;
use ipl\Html\HtmlElement;
use ipl\Html\Text;
+use ipl\Orm\Model;
use ipl\Validator\CallbackValidator;
use ipl\Web\FormDecorator\IcingaFormDecorator;
use ipl\Web\Widget\Icon;
+use Iterator;
use Traversable;
use function ipl\Stdlib\iterable_value_first;
@@ -141,10 +144,13 @@ class AddCommentForm extends CommandForm
(new IcingaFormDecorator())->decorate($this->getElement('btn_submit'));
}
- protected function getCommands(Traversable $objects): Traversable
+ protected function getCommands(Iterator $objects): Traversable
{
- $granted = $this->filterGrantedOn('icingadb/command/comment/add', $objects);
+ $granted = new CallbackFilterIterator($objects, function (Model $object): bool {
+ return $this->isGrantedOn('icingadb/command/comment/add', $object);
+ });
+ $granted->rewind(); // Forwards the pointer to the first element
if ($granted->valid()) {
$command = new AddCommentCommand();
$command->setObjects($granted);