aboutsummaryrefslogtreecommitdiff
path: root/lib/classes/ContentBar.php
diff options
context:
space:
mode:
authorThomas Hackl <hackl@data-quest.de>2022-12-12 15:20:27 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2022-12-12 15:20:27 +0000
commit936d1c00ea05bb0a5c56f441ff2eece6ccefada6 (patch)
tree10c4b9a4a1d02780112f7ddc99f9a88b37a1ad20 /lib/classes/ContentBar.php
parent54dbf11a35cac0de6fed1c50114c9583d210a40e (diff)
Resolve "StEP00348: Responsive Navigation Stud.IP 5.x"
Closes #32 Merge request studip/studip!65
Diffstat (limited to 'lib/classes/ContentBar.php')
-rw-r--r--lib/classes/ContentBar.php34
1 files changed, 25 insertions, 9 deletions
diff --git a/lib/classes/ContentBar.php b/lib/classes/ContentBar.php
index 043fe18..53b3dfc 100644
--- a/lib/classes/ContentBar.php
+++ b/lib/classes/ContentBar.php
@@ -15,25 +15,41 @@ class ContentBar
public $infoText = '';
public $icon = '';
public $toc = null;
+ public $actionMenu = null;
+
/**
- * ContentBar constructor.
- *
- * Note: An icon for consumer mode is always shown, this would have to be changed via template.
+ * The singleton instance of the container
+ */
+ protected static $instance = null;
+
+ /**
+ * Returns the instance of this container to ensure there is only one
+ * instance.
*
* @param TOCItem $toc Table of contents object.
* @param string $info Some information to show, like creation date, author etc.
* @param Icon|null $icon An icon to show in content bar.
* @param ActionMenu|null $actionMenu Optional action menu for page actions.
+ * @return ContentBar
+ * @static
*/
- public function __construct(TOCItem $toc, string $info = '', Icon $icon = null, ActionMenu $actionMenu = null)
+ public static function get(): ContentBar
{
- $this->infoText = $info;
- $this->icon = $icon;
- $this->toc = $toc;
- $this->actionMenu = $actionMenu;
+ if (static::$instance === null) {
+ static::$instance = new static;
+ }
+ return static::$instance;
}
- public $actionMenu = null;
+ /**
+ * Private constructor to ensure that the singleton Get() method is always
+ * used.
+ *
+ * @see ContentBar::get
+ */
+ protected function __construct()
+ {
+ }
/**
* Provide some info text.