From 71d08be4a3338935e89b3f64e56d8d816fd4a807 Mon Sep 17 00:00:00 2001 From: crynobone Date: Wed, 18 Mar 2015 18:01:42 +0800 Subject: [PATCH] Move bootUsingLaravel() to trait and add hasPackageRepository(). Signed-off-by: crynobone --- src/Providers/ServiceProvider.php | 12 -------- src/Providers/Traits/PackageProviderTrait.php | 28 ++++++++++++++++--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/Providers/ServiceProvider.php b/src/Providers/ServiceProvider.php index 1feeb2b..4a55402 100644 --- a/src/Providers/ServiceProvider.php +++ b/src/Providers/ServiceProvider.php @@ -6,16 +6,4 @@ abstract class ServiceProvider extends BaseServiceProvider { use PackageProviderTrait; - - /** - * Boot under Laravel setup. - * - * @param string $path - * - * @return void - */ - protected function bootUsingLaravel($path) - { - // - } } diff --git a/src/Providers/Traits/PackageProviderTrait.php b/src/Providers/Traits/PackageProviderTrait.php index 17f903f..71fb105 100644 --- a/src/Providers/Traits/PackageProviderTrait.php +++ b/src/Providers/Traits/PackageProviderTrait.php @@ -16,10 +16,8 @@ trait PackageProviderTrait */ public function addConfigComponent($package, $namespace, $path) { - $config = $this->app['config']; - - if ($config instanceof PackageRepository) { - $config->package($package, $path, $namespace); + if ($this->hasPackageRepository()) { + $this->app['config']->package($package, $path, $namespace); } } @@ -143,4 +141,26 @@ protected function getAppViewPaths($package) return "{$path}/packages/{$package}"; }, $this->app['config']['view.paths']); } + + /** + * Has package repository available. + * + * @return bool + */ + protected function hasPackageRepository() + { + return ($this->app['config'] instanceof PackageRepository); + } + + /** + * Boot under Laravel setup. + * + * @param string $path + * + * @return void + */ + protected function bootUsingLaravel($path) + { + // + } }