|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
/** |
|
5
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
6
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
7
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
8
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
9
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
10
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
11
|
|
|
* THE SOFTWARE. |
|
12
|
|
|
* |
|
13
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
14
|
|
|
* and is licensed under the MIT license. |
|
15
|
|
|
* |
|
16
|
|
|
* Copyright (c) 2014-2019 Yuuki Takezawa |
|
17
|
|
|
* |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace Ytake\LaravelSmarty; |
|
21
|
|
|
|
|
22
|
|
|
use Illuminate\Support\ServiceProvider; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Class SmartyConsoleServiceProvider |
|
26
|
|
|
* |
|
27
|
|
|
* @author yuuki.takezawa<[email protected]> |
|
28
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
|
29
|
|
|
*/ |
|
30
|
|
|
class SmartyConsoleServiceProvider extends ServiceProvider |
|
31
|
|
|
{ |
|
32
|
|
|
/** @var bool */ |
|
33
|
|
|
protected $defer = true; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
*/ |
|
37
|
|
|
public function boot() |
|
38
|
|
|
{ |
|
39
|
|
|
// register commands |
|
40
|
|
|
$this->registerCommands(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function register() |
|
47
|
|
|
{ |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Get the services provided by the provider. |
|
52
|
|
|
* |
|
53
|
|
|
* @return array |
|
54
|
|
|
*/ |
|
55
|
|
|
public function provides() |
|
56
|
|
|
{ |
|
57
|
|
|
return [ |
|
58
|
|
|
'command.ytake.laravel-smarty.clear.compiled', |
|
59
|
|
|
'command.ytake.laravel-smarty.clear.cache', |
|
60
|
|
|
'command.ytake.laravel-smarty.optimize', |
|
61
|
|
|
'command.ytake.laravel-smarty.info', |
|
62
|
|
|
]; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
*/ |
|
67
|
|
|
protected function registerCommands() |
|
68
|
|
|
{ |
|
69
|
|
|
// Package Info command |
|
70
|
|
|
$this->app->singleton('command.ytake.laravel-smarty.info', function () { |
|
71
|
|
|
return new Console\PackageInfoCommand; |
|
72
|
|
|
}); |
|
73
|
|
|
|
|
74
|
|
|
// cache clear |
|
75
|
|
|
$this->app->singleton('command.ytake.laravel-smarty.clear.cache', function ($app) { |
|
76
|
|
|
return new Console\CacheClearCommand($app['smarty.view']->getSmarty()); |
|
77
|
|
|
}); |
|
78
|
|
|
|
|
79
|
|
|
// clear compiled |
|
80
|
|
|
$this->app->singleton('command.ytake.laravel-smarty.clear.compiled', function ($app) { |
|
81
|
|
|
return new Console\ClearCompiledCommand($app['smarty.view']); |
|
82
|
|
|
}); |
|
83
|
|
|
|
|
84
|
|
|
// clear compiled |
|
85
|
|
|
$this->app->singleton('command.ytake.laravel-smarty.optimize', function ($app) { |
|
86
|
|
|
return new Console\OptimizeCommand($app['smarty.view']->getSmarty(), $app['config']); |
|
87
|
|
|
}); |
|
88
|
|
|
|
|
89
|
|
|
$this->commands( |
|
90
|
|
|
[ |
|
91
|
|
|
'command.ytake.laravel-smarty.clear.compiled', |
|
92
|
|
|
'command.ytake.laravel-smarty.clear.cache', |
|
93
|
|
|
'command.ytake.laravel-smarty.optimize', |
|
94
|
|
|
'command.ytake.laravel-smarty.info', |
|
95
|
|
|
] |
|
96
|
|
|
); |
|
97
|
|
|
} |
|
98
|
|
|
} |
|
99
|
|
|
|