From 1d2acf80967553e706d978789d06ff9eac8df885 Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 2 Dec 2015 17:24:12 +0200 Subject: [PATCH] Move onThemeInitialized event into Themes::initTheme() --- system/src/Grav/Common/Grav.php | 1 - system/src/Grav/Common/Themes.php | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/system/src/Grav/Common/Grav.php b/system/src/Grav/Common/Grav.php index eefef19a1..bb987f751 100644 --- a/system/src/Grav/Common/Grav.php +++ b/system/src/Grav/Common/Grav.php @@ -230,7 +230,6 @@ class Grav extends Container $debugger->startTimer('themes', 'Themes'); $this['themes']->init(); - $this->fireEvent('onThemeInitialized'); $debugger->stopTimer('themes'); $task = $this['task']; diff --git a/system/src/Grav/Common/Themes.php b/system/src/Grav/Common/Themes.php index 7c4c874ee..248b9d074 100644 --- a/system/src/Grav/Common/Themes.php +++ b/system/src/Grav/Common/Themes.php @@ -36,13 +36,18 @@ class Themes extends Iterator public function init() { - /** @var EventDispatcher $events */ - $events = $this->grav['events']; - /** @var Themes $themes */ $themes = $this->grav['themes']; $themes->configure(); + $this->initTheme(); + } + + public function initTheme() + { + /** @var Themes $themes */ + $themes = $this->grav['themes']; + try { $instance = $themes->load(); } catch (\InvalidArgumentException $e) { @@ -50,10 +55,15 @@ class Themes extends Iterator } if ($instance instanceof EventSubscriberInterface) { + /** @var EventDispatcher $events */ + $events = $this->grav['events']; + $events->addSubscriber($instance); } $this->grav['theme'] = $instance; + + $this->grav->fireEvent('onThemeInitialized'); } /**