mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-25 02:47:39 +02:00
BranchHelper: Define method return types
This commit is contained in:
parent
c9e78ba7d5
commit
cc3bfd5437
@ -9,6 +9,7 @@ use Icinga\Module\Director\Db\Branch\BranchSupport;
|
|||||||
use Icinga\Module\Director\Db\Branch\PreferredBranchSupport;
|
use Icinga\Module\Director\Db\Branch\PreferredBranchSupport;
|
||||||
use Icinga\Module\Director\Objects\IcingaObject;
|
use Icinga\Module\Director\Objects\IcingaObject;
|
||||||
use Icinga\Module\Director\Web\Widget\NotInBranchedHint;
|
use Icinga\Module\Director\Web\Widget\NotInBranchedHint;
|
||||||
|
use Ramsey\Uuid\UuidInterface;
|
||||||
|
|
||||||
trait BranchHelper
|
trait BranchHelper
|
||||||
{
|
{
|
||||||
@ -22,14 +23,17 @@ trait BranchHelper
|
|||||||
protected $hasPreferredBranch = null;
|
protected $hasPreferredBranch = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return false|\Ramsey\Uuid\UuidInterface
|
* @return ?UuidInterface
|
||||||
*/
|
*/
|
||||||
protected function getBranchUuid()
|
protected function getBranchUuid(): ?UuidInterface
|
||||||
{
|
{
|
||||||
return $this->getBranch()->getUuid();
|
return $this->getBranch()->getUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getBranch()
|
/**
|
||||||
|
* @return Branch
|
||||||
|
*/
|
||||||
|
protected function getBranch(): Branch
|
||||||
{
|
{
|
||||||
if ($this->branch === null) {
|
if ($this->branch === null) {
|
||||||
/** @var ActionController $this */
|
/** @var ActionController $this */
|
||||||
@ -42,7 +46,7 @@ trait BranchHelper
|
|||||||
/**
|
/**
|
||||||
* @return BranchStore
|
* @return BranchStore
|
||||||
*/
|
*/
|
||||||
protected function getBranchStore()
|
protected function getBranchStore(): BranchStore
|
||||||
{
|
{
|
||||||
if ($this->branchStore === null) {
|
if ($this->branchStore === null) {
|
||||||
$this->branchStore = new BranchStore($this->db());
|
$this->branchStore = new BranchStore($this->db());
|
||||||
@ -51,12 +55,15 @@ trait BranchHelper
|
|||||||
return $this->branchStore;
|
return $this->branchStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function hasBranch()
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
protected function hasBranch(): bool
|
||||||
{
|
{
|
||||||
return $this->getBranchUuid() !== null;
|
return $this->getBranchUuid() !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function enableStaticObjectLoader($table)
|
protected function enableStaticObjectLoader($table): void
|
||||||
{
|
{
|
||||||
if (BranchSupport::existsForTableName($table)) {
|
if (BranchSupport::existsForTableName($table)) {
|
||||||
IcingaObject::setDbObjectStore(new DbObjectStore($this->db(), $this->getBranch()));
|
IcingaObject::setDbObjectStore(new DbObjectStore($this->db(), $this->getBranch()));
|
||||||
@ -67,7 +74,7 @@ trait BranchHelper
|
|||||||
* @param string $subject
|
* @param string $subject
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function showNotInBranch($subject)
|
protected function showNotInBranch($subject): bool
|
||||||
{
|
{
|
||||||
if ($this->getBranch()->isBranch()) {
|
if ($this->getBranch()->isBranch()) {
|
||||||
$this->content()->add(new NotInBranchedHint($subject, $this->getBranch(), $this->Auth()));
|
$this->content()->add(new NotInBranchedHint($subject, $this->getBranch(), $this->Auth()));
|
||||||
@ -77,7 +84,7 @@ trait BranchHelper
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function hasPreferredBranch()
|
protected function hasPreferredBranch(): bool
|
||||||
{
|
{
|
||||||
if ($this->hasPreferredBranch === null) {
|
if ($this->hasPreferredBranch === null) {
|
||||||
$implementation = Branch::optionalHook();
|
$implementation = Branch::optionalHook();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user