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