From cd989f9c3aff968e19a3aeabc4eb9085787a6673 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 14:43:12 +0200 Subject: Adding upstream version 1.10.2. Signed-off-by: Daniel Baumann --- library/Director/Web/Controller/BranchHelper.php | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 library/Director/Web/Controller/BranchHelper.php (limited to 'library/Director/Web/Controller/BranchHelper.php') diff --git a/library/Director/Web/Controller/BranchHelper.php b/library/Director/Web/Controller/BranchHelper.php new file mode 100644 index 0000000..ac2a480 --- /dev/null +++ b/library/Director/Web/Controller/BranchHelper.php @@ -0,0 +1,76 @@ +getBranch()->getUuid(); + } + + protected function getBranch() + { + if ($this->branch === null) { + /** @var ActionController $this */ + $this->branch = Branch::forRequest($this->getRequest(), $this->getBranchStore(), $this->Auth()); + } + + return $this->branch; + } + + /** + * @return BranchStore + */ + protected function getBranchStore() + { + if ($this->branchStore === null) { + $this->branchStore = new BranchStore($this->db()); + } + + return $this->branchStore; + } + + protected function hasBranch() + { + return $this->getBranchUuid() !== null; + } + + protected function enableStaticObjectLoader($table) + { + if (BranchSupport::existsForTableName($table)) { + IcingaObject::setDbObjectStore(new DbObjectStore($this->db(), $this->getBranch())); + } + } + + /** + * @param string $subject + * @return bool + */ + protected function showNotInBranch($subject) + { + if ($this->getBranch()->isBranch()) { + $this->content()->add(new NotInBranchedHint($subject, $this->getBranch(), $this->Auth())); + return true; + } + + return false; + } +} -- cgit v1.2.3