From 354b76635387e336cb6832a2565bb2a3562b00b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Bj=C3=B8rnskov?= Date: Wed, 27 Aug 2014 12:35:07 +0200 Subject: [PATCH] Register clean up --- src/Silex/Application.php | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Silex/Application.php b/src/Silex/Application.php index 0ad08e91a..5a2055c75 100644 --- a/src/Silex/Application.php +++ b/src/Silex/Application.php @@ -143,11 +143,7 @@ public function register(ServiceProviderInterface $provider, array $values = arr { $this->providers[] = $provider; - $provider->register($this); - - foreach ($values as $key => $value) { - $this[$key] = $value; - } + parent::register($provider, $values); return $this; } @@ -160,17 +156,19 @@ public function register(ServiceProviderInterface $provider, array $values = arr */ public function boot() { - if (!$this->booted) { - $this->booted = true; + if ($this->booted) { + return; + } - foreach ($this->providers as $provider) { - if ($provider instanceof EventListenerProviderInterface) { - $provider->subscribe($this, $this['dispatcher']); - } + $this->booted = true; + + foreach ($this->providers as $provider) { + if ($provider instanceof EventListenerProviderInterface) { + $provider->subscribe($this, $this['dispatcher']); + } - if ($provider instanceof BootableProviderInterface) { - $provider->boot($this); - } + if ($provider instanceof BootableProviderInterface) { + $provider->boot($this); } } }