diff --git a/.travis.yml b/.travis.yml index f60bbe0..af6fce2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,15 @@ php: - 5.6 - hhvm +env: + - LARAVEL_VERSION="4.2.*" + - LARAVEL_VERSION="5.0.*" + before_script: - travis_retry composer self-update + - travis_retry composer require laravel/framework:${LARAVEL_VERSION} --no-update + - travis_retry composer require illuminate/support:${LARAVEL_VERSION} --no-update + - travis_retry composer require illuminate/database:${LARAVEL_VERSION} --no-update - travis_retry composer install --prefer-source --no-interaction --dev script: phpunit diff --git a/composer.json b/composer.json index ff666e2..25b7670 100644 --- a/composer.json +++ b/composer.json @@ -12,8 +12,8 @@ ], "require": { "php": ">=5.4.0", - "illuminate/support": "4.2.*", - "illuminate/database": "4.2.*", + "illuminate/support": ">=4.2", + "illuminate/database": ">=4.2", "get-stream/stream": "~2.1" }, "require-dev": { @@ -27,3 +27,4 @@ }, "minimum-stability": "stable" } + diff --git a/src/GetStream/StreamLaravel/StreamLaravelManager.php b/src/GetStream/StreamLaravel/StreamLaravelManager.php index 95c438d..646e140 100644 --- a/src/GetStream/StreamLaravel/StreamLaravelManager.php +++ b/src/GetStream/StreamLaravel/StreamLaravelManager.php @@ -78,4 +78,4 @@ public function activityDeleted($instance) $feed->removeActivity($foreignId, true); } -} +} \ No newline at end of file diff --git a/src/GetStream/StreamLaravel/StreamLaravelServiceProvider.php b/src/GetStream/StreamLaravel/StreamLaravelServiceProvider.php index ff1666b..7e3eba8 100644 --- a/src/GetStream/StreamLaravel/StreamLaravelServiceProvider.php +++ b/src/GetStream/StreamLaravel/StreamLaravelServiceProvider.php @@ -18,7 +18,16 @@ class StreamLaravelServiceProvider extends ServiceProvider { */ public function boot() { - $this->package('get-stream/stream-laravel'); + if (method_exists($this, 'publishes')) { + $this->loadViewsFrom(__DIR__.'/../../views', 'stream-laravel'); + + $this->publishes([ + __DIR__.'/../../config/config.php' => config_path('stream-laravel.php'), + __DIR__.'/../../views' => base_path('resources/views/vendor/stream-laravel'), + ]); + } else { + $this->package('get-stream/stream-laravel'); + } } /** @@ -28,15 +37,45 @@ public function boot() */ public function register() { + + if (method_exists($this, 'publishes')) { + $this->registerResources(); + } + $this->app['feed_manager'] = $this->app->share(function($app) { + $manager_class = $app['config']->get('stream-laravel::feed_manager_class'); $api_key = $app['config']->get('stream-laravel::api_key'); $api_secret = $app['config']->get('stream-laravel::api_secret'); - return new $manager_class($api_key, $api_secret, $app['config']); + + return new $manager_class($api_key, $api_secret, $this->app['config']); }); } + /** + * Register the package resources. + * + * @return void + */ + protected function registerResources() + { + $userConfigFile = app()->configPath().'/stream-laravel.php'; + $packageConfigFile = __DIR__.'/../../config/config.php'; + $config = $this->app['files']->getRequire($packageConfigFile); + + if (file_exists($userConfigFile)) { + $userConfig = $this->app['files']->getRequire($userConfigFile); + $config = array_replace_recursive($config, $userConfig); + } + + $namespace = 'stream-laravel::'; + + foreach($config as $key => $value) { + $this->app['config']->set($namespace . $key , $value); + } + } + /** * Get the services provided by the provider. * diff --git a/src/config/config.php b/src/config/config.php index c0d901c..dc6e854 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -1,6 +1,6 @@ 'flat', 'aggregated' => 'aggregated', ) -); \ No newline at end of file +]; \ No newline at end of file diff --git a/src/views/render_activity.blade.php b/src/views/render_activity.blade.php index 83be02d..9d2df23 100644 --- a/src/views/render_activity.blade.php +++ b/src/views/render_activity.blade.php @@ -13,5 +13,6 @@ @endif @endif @else - {{ ''; Log::warning('The activity could not be rendered, the following field/refs could not be enriched:', $activity->getNotEnrichedData()); }} + {{ '' }} + Log::warning('The activity could not be rendered, the following field/refs could not be enriched:', $activity->getNotEnrichedData()); @endif