|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Publiux\laravelcdn; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class CdnServiceProvider. |
|
9
|
|
|
* |
|
10
|
|
|
* @category Service Provider |
|
11
|
|
|
* |
|
12
|
|
|
* @author Mahmoud Zalt <[email protected]> |
|
13
|
|
|
* @author Abed Halawi <[email protected]> |
|
14
|
|
|
*/ |
|
15
|
|
|
class CdnServiceProvider 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
|
|
|
public function boot() |
|
30
|
|
|
{ |
|
31
|
|
|
$this->publishes([ |
|
32
|
|
|
__DIR__.'/../../config/cdn.php' => config_path('cdn.php'), |
|
33
|
|
|
]); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Register the service provider. |
|
38
|
|
|
* |
|
39
|
|
|
* @return void |
|
40
|
|
|
*/ |
|
41
|
|
|
public function register() |
|
42
|
|
|
{ |
|
43
|
|
|
|
|
44
|
|
|
// implementation bindings: |
|
45
|
|
|
//------------------------- |
|
46
|
|
|
$this->app->bind( |
|
47
|
|
|
'Publiux\laravelcdn\Contracts\CdnInterface', |
|
48
|
|
|
'Publiux\laravelcdn\Cdn' |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
$this->app->bind( |
|
52
|
|
|
'Publiux\laravelcdn\Providers\Contracts\ProviderInterface', |
|
53
|
|
|
'Publiux\laravelcdn\Providers\AwsS3Provider' |
|
54
|
|
|
); |
|
55
|
|
|
|
|
56
|
|
|
$this->app->bind( |
|
57
|
|
|
'Publiux\laravelcdn\Contracts\AssetInterface', |
|
58
|
|
|
'Publiux\laravelcdn\Asset' |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
$this->app->bind( |
|
62
|
|
|
'Publiux\laravelcdn\Contracts\FinderInterface', |
|
63
|
|
|
'Publiux\laravelcdn\Finder' |
|
64
|
|
|
); |
|
65
|
|
|
|
|
66
|
|
|
$this->app->bind( |
|
67
|
|
|
'Publiux\laravelcdn\Contracts\ProviderFactoryInterface', |
|
68
|
|
|
'Publiux\laravelcdn\ProviderFactory' |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
$this->app->bind( |
|
72
|
|
|
'Publiux\laravelcdn\Contracts\CdnFacadeInterface', |
|
73
|
|
|
'Publiux\laravelcdn\CdnFacade' |
|
74
|
|
|
); |
|
75
|
|
|
|
|
76
|
|
|
$this->app->bind( |
|
77
|
|
|
'Publiux\laravelcdn\Contracts\CdnHelperInterface', |
|
78
|
|
|
'Publiux\laravelcdn\CdnHelper' |
|
79
|
|
|
); |
|
80
|
|
|
|
|
81
|
|
|
$this->app->bind( |
|
82
|
|
|
'Publiux\laravelcdn\Validators\Contracts\ProviderValidatorInterface', |
|
83
|
|
|
'Publiux\laravelcdn\Validators\ProviderValidator' |
|
84
|
|
|
); |
|
85
|
|
|
|
|
86
|
|
|
$this->app->bind( |
|
87
|
|
|
'Publiux\laravelcdn\Validators\Contracts\CdnFacadeValidatorInterface', |
|
88
|
|
|
'Publiux\laravelcdn\Validators\CdnFacadeValidator' |
|
89
|
|
|
); |
|
90
|
|
|
|
|
91
|
|
|
$this->app->bind( |
|
92
|
|
|
'Publiux\laravelcdn\Validators\Contracts\ValidatorInterface', |
|
93
|
|
|
'Publiux\laravelcdn\Validators\Validator' |
|
94
|
|
|
); |
|
95
|
|
|
|
|
96
|
|
|
// register the commands: |
|
97
|
|
|
//----------------------- |
|
98
|
|
|
$this->app->singleton('cdn.push', function ($app) { |
|
99
|
|
|
return $app->make('Publiux\laravelcdn\Commands\PushCommand'); |
|
100
|
|
|
}); |
|
101
|
|
|
|
|
102
|
|
|
$this->commands('cdn.push'); |
|
103
|
|
|
|
|
104
|
|
|
$this->app->singleton('cdn.empty', function ($app) { |
|
105
|
|
|
return $app->make('Publiux\laravelcdn\Commands\EmptyCommand'); |
|
106
|
|
|
}); |
|
107
|
|
|
|
|
108
|
|
|
$this->commands('cdn.empty'); |
|
109
|
|
|
|
|
110
|
|
|
// facade bindings: |
|
111
|
|
|
//----------------- |
|
112
|
|
|
|
|
113
|
|
|
// Register 'CdnFacade' instance container to our CdnFacade object |
|
114
|
|
|
$this->app->singleton('CDN', function ($app) { |
|
115
|
|
|
return $app->make('Publiux\laravelcdn\CdnFacade'); |
|
116
|
|
|
}); |
|
117
|
|
|
|
|
118
|
|
|
// Shortcut so developers don't need to add an Alias in app/config/app.php |
|
119
|
|
|
// $this->app->booting(function () { |
|
120
|
|
|
// $loader = \Illuminate\Foundation\AliasLoader::getInstance(); |
|
121
|
|
|
// $loader->alias('Cdn', 'Publiux\laravelcdn\Facades\CdnFacadeAccessor'); |
|
122
|
|
|
// }); |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
/** |
|
126
|
|
|
* Get the services provided by the provider. |
|
127
|
|
|
* |
|
128
|
|
|
* @return array |
|
129
|
|
|
*/ |
|
130
|
|
|
public function provides() |
|
131
|
|
|
{ |
|
132
|
|
|
return []; |
|
133
|
|
|
} |
|
134
|
|
|
} |
|
135
|
|
|
|