Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

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