diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-02 02:09:56 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-09-02 02:09:56 +0200 |
commit | 9e217d87c095170460a8580d5215ddf7cbe639f4 (patch) | |
tree | 3b426fe52e70ef0f1395edcb354f1be4788ca329 /src/Renderer/Twig/Extensions/Globals.php | |
parent | ac48332166ce28fcb1a2fc130c7f5adbc760e42d (diff) |
Template refactoring to use twig
Diffstat (limited to 'src/Renderer/Twig/Extensions/Globals.php')
-rw-r--r-- | src/Renderer/Twig/Extensions/Globals.php | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/Renderer/Twig/Extensions/Globals.php b/src/Renderer/Twig/Extensions/Globals.php index f9bffbc8..1a4df42c 100644 --- a/src/Renderer/Twig/Extensions/Globals.php +++ b/src/Renderer/Twig/Extensions/Globals.php @@ -2,6 +2,7 @@ namespace Engelsystem\Renderer\Twig\Extensions; +use Carbon\Carbon; use Twig_Extension as TwigExtension; use Twig_Extension_GlobalsInterface as GlobalsInterface; @@ -16,8 +17,45 @@ class Globals extends TwigExtension implements GlobalsInterface { global $user; + $eventConfig = $this->getEventConfig(); + if (empty($eventConfig)) { + $eventConfig = []; + } + return [ - 'user' => isset($user) ? $user : [], + 'user' => isset($user) ? $user : [], + 'event_config' => $this->filterEventConfig($eventConfig), ]; } + + /** + * @return array + * @codeCoverageIgnore + */ + protected function getEventConfig() + { + return EventConfig(); + } + + /** + * @param $eventConfig + * @return mixed + */ + protected function filterEventConfig($eventConfig) + { + array_walk($eventConfig, function (&$value, $key) { + if (is_null($value) || !in_array($key, [ + 'buildup_start_date', + 'event_start_date', + 'event_end_date', + 'teardown_end_date', + ])) { + return; + } + + $value = Carbon::createFromTimestamp($value); + }); + + return $eventConfig; + } } |