Skip to content

Commit 682e626

Browse files
committed
Merge pull request #13 from peachepe/master
laravel 5 support
2 parents d929fc9 + bc3659b commit 682e626

File tree

6 files changed

+56
-8
lines changed

6 files changed

+56
-8
lines changed

.travis.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,15 @@ php:
66
- 5.6
77
- hhvm
88

9+
env:
10+
- LARAVEL_VERSION="4.2.*"
11+
- LARAVEL_VERSION="5.0.*"
12+
913
before_script:
1014
- travis_retry composer self-update
15+
- travis_retry composer require laravel/framework:${LARAVEL_VERSION} --no-update
16+
- travis_retry composer require illuminate/support:${LARAVEL_VERSION} --no-update
17+
- travis_retry composer require illuminate/database:${LARAVEL_VERSION} --no-update
1118
- travis_retry composer install --prefer-source --no-interaction --dev
1219

1320
script: phpunit

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
],
1313
"require": {
1414
"php": ">=5.4.0",
15-
"illuminate/support": "4.2.*",
16-
"illuminate/database": "4.2.*",
15+
"illuminate/support": ">=4.2",
16+
"illuminate/database": ">=4.2",
1717
"get-stream/stream": "~2.1"
1818
},
1919
"require-dev": {
@@ -27,3 +27,4 @@
2727
},
2828
"minimum-stability": "stable"
2929
}
30+

src/GetStream/StreamLaravel/StreamLaravelManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,4 @@ public function activityDeleted($instance)
7878
$feed->removeActivity($foreignId, true);
7979
}
8080

81-
}
81+
}

src/GetStream/StreamLaravel/StreamLaravelServiceProvider.php

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*

src/config/config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
return array(
3+
return [
44

55
/*
66
|-----------------------------------------------------------------------------
@@ -46,4 +46,4 @@
4646
'flat' => 'flat',
4747
'aggregated' => 'aggregated',
4848
)
49-
);
49+
];

src/views/render_activity.blade.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
@endif
1414
@endif
1515
@else
16-
{{ ''; Log::warning('The activity could not be rendered, the following field/refs could not be enriched:', $activity->getNotEnrichedData()); }}
16+
{{ '' }}
17+
Log::warning('The activity could not be rendered, the following field/refs could not be enriched:', $activity->getNotEnrichedData());
1718
@endif

0 commit comments

Comments
 (0)