TableWithBranchSupport: provide setter

This commit is contained in:
Thomas Gelf 2022-09-20 12:20:44 +02:00
parent 3c8bb6bd16
commit 131d4e27ba

View File

@ -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;