From 33f04d9e52d12154ca5e118cc3f28548be52f5ad Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 25 Jan 2018 13:14:33 +0100 Subject: [PATCH] PropertyModifierHook: add missing methods, cleanup refs #1369 --- .../Director/Hook/PropertyModifierHook.php | 39 ++++++++++++++++--- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/library/Director/Hook/PropertyModifierHook.php b/library/Director/Hook/PropertyModifierHook.php index 1aa14615..aa846911 100644 --- a/library/Director/Hook/PropertyModifierHook.php +++ b/library/Director/Hook/PropertyModifierHook.php @@ -7,15 +7,19 @@ use Icinga\Module\Director\Db; abstract class PropertyModifierHook { - protected $settings = array(); + /** @var array */ + protected $settings = []; + /** @var string */ private $targetProperty; + /** @var Db */ private $db; - /** - * @var \stdClass - */ + /** @var bool */ + private $rejected = false; + + /** @var \stdClass */ private $row; /** @@ -23,7 +27,7 @@ abstract class PropertyModifierHook * * Your custom property modifier needs to implement this method. * - * @return value + * @return mixed $value */ abstract public function transform($value); @@ -55,6 +59,21 @@ abstract class PropertyModifierHook return false; } + /** + * Reject this whole row + * + * Allows your property modifier to reject specific rows + * + * @param bool $reject + * @return $this + */ + public function rejectRow($reject = true) + { + $this->rejected = (bool) $reject; + + return $this; + } + /** * Whether this PropertyModifier wants access to the current row * @@ -67,6 +86,16 @@ abstract class PropertyModifierHook return false; } + /** + * Whether this modifier wants to reject the current row + * + * @return bool + */ + public function rejectsRow() + { + return $this->rejected; + } + /** * Get the current row *