Skip to content

Commit ca2dee3

Browse files
committed
add global properties to Views
1 parent ca79afa commit ca2dee3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Mvc/View.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ class View
1313
*/
1414
private static $extension = 'phtml';
1515

16+
/**
17+
* @var array
18+
*/
19+
private static $globals = [];
20+
1621
/**
1722
* @var TemplateEngine
1823
*/
@@ -36,6 +41,14 @@ public static function setExtension(string $extension)
3641
self::$extension = $extension;
3742
}
3843

44+
/**
45+
* @param array $globals
46+
*/
47+
public static function setGlobals(array $globals)
48+
{
49+
self::$globals = $globals;
50+
}
51+
3952
/**
4053
* Draw a template using application defined
4154
* template engine.
@@ -56,7 +69,7 @@ public function draw()
5669

5770
return $this->templateEngine->draw(
5871
$file,
59-
$this->data
72+
array_merge(static::$globals, $this->data)
6073
);
6174
}
6275

0 commit comments

Comments
 (0)