|
1 | | -<?php namespace GetStream\StreamLaravel; |
| 1 | +<?php |
2 | 2 |
|
3 | | -use Illuminate\Support\ServiceProvider; |
4 | | - |
5 | | -class StreamLumenServiceProvider extends ServiceProvider { |
6 | | - |
7 | | - /** |
8 | | - * Indicates if loading of the provider is deferred. |
9 | | - * |
10 | | - * @var bool |
11 | | - */ |
12 | | - protected $defer = false; |
| 3 | +namespace GetStream\StreamLaravel; |
13 | 4 |
|
14 | | - /** |
15 | | - * Bootstrap the application events. |
16 | | - * |
17 | | - * @return void |
18 | | - */ |
19 | | - public function boot() |
20 | | - { |
21 | | - if (method_exists($this, 'publishes')) { |
22 | | - $this->loadViewsFrom(__DIR__.'/../../views', 'stream-laravel'); |
| 5 | +use Illuminate\Support\ServiceProvider; |
23 | 6 |
|
24 | | - $this->publishes([ |
25 | | - __DIR__.'/../../config/config.php' => app()->configure('stream-laravel.php'), |
26 | | - __DIR__.'/../../views' => base_path('resources/views/vendor/stream-laravel'), |
27 | | - ]); |
28 | | - } else { |
29 | | - $this->package('get-stream/stream-laravel'); |
30 | | - } |
31 | | - } |
| 7 | +class StreamLumenServiceProvider extends ServiceProvider |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Bootstrap the application events. |
| 11 | + * |
| 12 | + * @return void |
| 13 | + */ |
| 14 | + public function boot() |
| 15 | + { |
| 16 | + if (method_exists($this, 'publishes')) { |
| 17 | + $this->loadViewsFrom(__DIR__.'/../../views', 'stream-laravel'); |
32 | 18 |
|
33 | | - /** |
34 | | - * Register the service provider. |
35 | | - * |
36 | | - * @return void |
37 | | - */ |
38 | | - public function register() |
39 | | - { |
| 19 | + $this->publishes([ |
| 20 | + __DIR__.'/../../config/config.php' => app()->configure('stream-laravel.php'), |
| 21 | + __DIR__.'/../../views' => base_path('resources/views/vendor/stream-laravel'), |
| 22 | + ]); |
| 23 | + } else { |
| 24 | + $this->package('get-stream/stream-laravel'); |
| 25 | + } |
| 26 | + } |
40 | 27 |
|
41 | | - if (method_exists($this, 'publishes')) { |
42 | | - $this->registerResources(); |
43 | | - } |
| 28 | + /** |
| 29 | + * Register the service provider. |
| 30 | + * |
| 31 | + * @return void |
| 32 | + */ |
| 33 | + public function register() |
| 34 | + { |
| 35 | + if (method_exists($this, 'publishes')) { |
| 36 | + $this->registerResources(); |
| 37 | + } |
44 | 38 |
|
45 | | - $this->app->singleton('feed_manager', function($app) |
46 | | - { |
47 | | - $manager_class = config('stream-laravel.feed_manager_class'); |
48 | | - $api_key = config('stream-laravel.api_key'); |
49 | | - $api_secret = config('stream-laravel.api_secret'); |
| 39 | + $this->app->singleton('feed_manager', function($app) { |
| 40 | + $manager_class = config('stream-laravel.feed_manager_class'); |
| 41 | + $api_key = config('stream-laravel.api_key'); |
| 42 | + $api_secret = config('stream-laravel.api_secret'); |
50 | 43 |
|
51 | 44 | return new $manager_class($api_key, $api_secret, $this->app['config']); |
52 | 45 | }); |
53 | | - } |
54 | | - |
55 | | - /** |
56 | | - * Register the package resources. |
57 | | - * |
58 | | - * @return void |
59 | | - */ |
60 | | - protected function registerResources() |
61 | | - { |
62 | | - $userConfigFile = app()->configure('stream-laravel.php'); |
63 | | - $packageConfigFile = __DIR__.'/../../config/config.php'; |
64 | | - $config = $this->app['files']->getRequire($packageConfigFile); |
65 | | - |
66 | | - if (file_exists($userConfigFile)) { |
67 | | - $userConfig = $this->app['files']->getRequire($userConfigFile); |
68 | | - $config = array_replace_recursive($config, $userConfig); |
69 | | - } |
| 46 | + } |
70 | 47 |
|
71 | | - $namespace = 'stream-laravel::'; |
| 48 | + /** |
| 49 | + * Register the package resources. |
| 50 | + * |
| 51 | + * @return void |
| 52 | + */ |
| 53 | + protected function registerResources() |
| 54 | + { |
| 55 | + $userConfigFile = app()->configure('stream-laravel.php'); |
| 56 | + $packageConfigFile = __DIR__.'/../../config/config.php'; |
| 57 | + $config = $this->app['files']->getRequire($packageConfigFile); |
72 | 58 |
|
73 | | - foreach($config as $key => $value) { |
74 | | - $this->app['config']->set($namespace . $key , $value); |
75 | | - } |
76 | | - } |
| 59 | + if (file_exists($userConfigFile)) { |
| 60 | + $userConfig = $this->app['files']->getRequire($userConfigFile); |
| 61 | + $config = array_replace_recursive($config, $userConfig); |
| 62 | + } |
77 | 63 |
|
78 | | - /** |
79 | | - * Get the services provided by the provider. |
80 | | - * |
81 | | - * @return array |
82 | | - */ |
83 | | - public function provides() |
84 | | - { |
85 | | - return array(); |
86 | | - } |
| 64 | + $namespace = 'stream-laravel::'; |
87 | 65 |
|
| 66 | + foreach($config as $key => $value) { |
| 67 | + $this->app['config']->set($namespace . $key , $value); |
| 68 | + } |
| 69 | + } |
88 | 70 | } |
0 commit comments