diff --git a/library/Director/Web/Table/TableWithBranchSupport.php b/library/Director/Web/Table/TableWithBranchSupport.php index 903bd85f..7c5b15cc 100644 --- a/library/Director/Web/Table/TableWithBranchSupport.php +++ b/library/Director/Web/Table/TableWithBranchSupport.php @@ -2,6 +2,7 @@ namespace Icinga\Module\Director\Web\Table; +use Icinga\Module\Director\Db\Branch\Branch; use Ramsey\Uuid\UuidInterface; trait TableWithBranchSupport @@ -10,6 +11,21 @@ trait TableWithBranchSupport /** @var UuidInterface|null */ protected $branchUuid; + /** + * Convenience method, only UUID is required + * + * @param Branch|null $branch + * @return $this + */ + public function setBranch(Branch $branch = null) + { + if ($branch && $branch->isBranch()) { + $this->setBranchUuid($branch->getUuid()); + } + + return $this; + } + public function setBranchUuid(UuidInterface $uuid = null) { $this->branchUuid = $uuid;