@@ -18,7 +18,16 @@ class StreamLaravelServiceProvider extends ServiceProvider {
1818 */
1919 public function boot ()
2020 {
21- $ this ->package ('get-stream/stream-laravel ' );
21+ if (method_exists ($ this , 'publishes ' )) {
22+ $ this ->loadViewsFrom (__DIR__ .'/../../views ' , 'stream-laravel ' );
23+
24+ $ this ->publishes ([
25+ __DIR__ .'/../../config/config.php ' => config_path ('stream-laravel.php ' ),
26+ __DIR__ .'/../../views ' => base_path ('resources/views/vendor/stream-laravel ' ),
27+ ]);
28+ } else {
29+ $ this ->package ('get-stream/stream-laravel ' );
30+ }
2231 }
2332
2433 /**
@@ -28,15 +37,45 @@ public function boot()
2837 */
2938 public function register ()
3039 {
40+
41+ if (method_exists ($ this , 'publishes ' )) {
42+ $ this ->registerResources ();
43+ }
44+
3145 $ this ->app ['feed_manager ' ] = $ this ->app ->share (function ($ app )
3246 {
47+
3348 $ manager_class = $ app ['config ' ]->get ('stream-laravel::feed_manager_class ' );
3449 $ api_key = $ app ['config ' ]->get ('stream-laravel::api_key ' );
3550 $ api_secret = $ app ['config ' ]->get ('stream-laravel::api_secret ' );
36- return new $ manager_class ($ api_key , $ api_secret , $ app ['config ' ]);
51+
52+ return new $ manager_class ($ api_key , $ api_secret , $ this ->app ['config ' ]);
3753 });
3854 }
3955
56+ /**
57+ * Register the package resources.
58+ *
59+ * @return void
60+ */
61+ protected function registerResources ()
62+ {
63+ $ userConfigFile = app ()->configPath ().'/stream-laravel.php ' ;
64+ $ packageConfigFile = __DIR__ .'/../../config/config.php ' ;
65+ $ config = $ this ->app ['files ' ]->getRequire ($ packageConfigFile );
66+
67+ if (file_exists ($ userConfigFile )) {
68+ $ userConfig = $ this ->app ['files ' ]->getRequire ($ userConfigFile );
69+ $ config = array_replace_recursive ($ config , $ userConfig );
70+ }
71+
72+ $ namespace = 'stream-laravel:: ' ;
73+
74+ foreach ($ config as $ key => $ value ) {
75+ $ this ->app ['config ' ]->set ($ namespace . $ key , $ value );
76+ }
77+ }
78+
4079 /**
4180 * Get the services provided by the provider.
4281 *
0 commit comments