summaryrefslogtreecommitdiff
path: root/app/View.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2018-01-14 18:39:01 +0000
committerGreg Roach <fisharebest@gmail.com>2018-01-14 19:21:15 +0000
commit08d24c7a77efecac8411cad1ad1da3bc99726eb1 (patch)
treee6401bb4e42e3cba9c96846b1dd612ea944908c6 /app/View.php
parent514be21cb4c00e9dee0e53417d6b5661b77c2539 (diff)
downloadwebtrees-08d24c7a77efecac8411cad1ad1da3bc99726eb1.tar.gz
webtrees-08d24c7a77efecac8411cad1ad1da3bc99726eb1.tar.bz2
webtrees-08d24c7a77efecac8411cad1ad1da3bc99726eb1.zip
Add support for shared view data
Diffstat (limited to 'app/View.php')
-rw-r--r--app/View.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/app/View.php b/app/View.php
index d081dce0e2..80b7d8aeaf 100644
--- a/app/View.php
+++ b/app/View.php
@@ -30,6 +30,11 @@ class View {
private $data;
/**
+ * @var mixed[] Data to be inserted into all views.
+ */
+ private static $shared_data = [];
+
+ /**
* @var string Implementation of Blade "stacks".
*/
private static $stack;
@@ -51,6 +56,13 @@ class View {
}
/**
+ * Shared data that is available to all views.
+ */
+ public static function share($key, $value) {
+ self::$shared_data[$key] = $value;
+ }
+
+ /**
* Implementation of Blade "stacks".
*
* @see https://laravel.com/docs/5.5/blade#stacks
@@ -86,7 +98,7 @@ class View {
* @return string
*/
public function render() {
- extract($this->data);
+ extract($this->data + self::$shared_data);
ob_start();
require $this->getFilenameForView($this->name);