1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of Friends. |
4
|
|
|
* |
5
|
|
|
* (c) Christopher Lass <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Arubacao\Friends; |
12
|
|
|
|
13
|
|
|
use Illuminate\Support\ServiceProvider; |
14
|
|
|
|
15
|
|
|
class FriendsServiceProvider extends ServiceProvider |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Indicates if loading of the provider is deferred. |
19
|
|
|
* |
20
|
|
|
* @var bool |
21
|
|
|
*/ |
22
|
|
|
protected $defer = false; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Bootstrap the application events. |
26
|
|
|
* |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
26 |
|
public function boot() |
30
|
|
|
{ |
31
|
26 |
|
$this->publishConfig(); |
32
|
26 |
|
$this->publishMigration(); |
33
|
26 |
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Publish Friends configuration. |
37
|
|
|
*/ |
38
|
26 |
|
protected function publishConfig() |
39
|
|
|
{ |
40
|
26 |
|
if (function_exists('config_path')) { |
41
|
|
|
// Publish config files |
42
|
26 |
|
$this->publishes([ |
43
|
26 |
|
__DIR__.'/../config/friends.php' => config_path('friends.php'), |
44
|
26 |
|
]); |
45
|
26 |
|
} |
46
|
26 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Publish Friends migration. |
50
|
|
|
*/ |
51
|
26 |
|
protected function publishMigration() |
52
|
|
|
{ |
53
|
26 |
|
if (class_exists('CreateFriendsTable')) { |
54
|
25 |
|
return; |
55
|
|
|
} |
56
|
|
|
|
57
|
1 |
|
$published_migration = glob(database_path('/migrations/*_create_friends_table.php')); |
58
|
1 |
|
if (count($published_migration) != 0) { |
59
|
|
|
return; |
60
|
|
|
} |
61
|
|
|
|
62
|
1 |
|
$stub = __DIR__.'/../database/migrations/2016_06_18_000000_create_friends_table.php'; |
63
|
1 |
|
$target = database_path('/migrations/'.date('Y_m_d_His').'_create_friends_table.php'); |
64
|
1 |
|
$this->publishes([$stub => $target], 'migrations'); |
65
|
26 |
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Register the service provider. |
69
|
|
|
* |
70
|
|
|
* @return void |
71
|
|
|
*/ |
72
|
26 |
|
public function register() |
73
|
|
|
{ |
74
|
26 |
|
if(method_exists($this->app,'configure')) { |
75
|
|
|
$this->app->configure('friends'); |
|
|
|
|
76
|
|
|
} |
77
|
26 |
|
$this->mergeConfig(); |
78
|
26 |
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Merges user's and friends's configs. |
82
|
|
|
* |
83
|
|
|
* @return void |
84
|
|
|
*/ |
85
|
26 |
|
protected function mergeConfig() |
86
|
|
|
{ |
87
|
26 |
|
$this->mergeConfigFrom( |
88
|
26 |
|
__DIR__.'/../config/friends.php', 'friends' |
89
|
26 |
|
); |
90
|
26 |
|
} |
91
|
|
|
} |
92
|
|
|
|
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.