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\Console;
22
 
23
use Illuminate\Console\Command;
24
use Symfony\Component\Console\Input\InputOption;
25
use Ytake\LaravelSmarty\SmartyFactory;
26
 
27
/**
28
 * Class ClearCompiledCommand
29
 *
30
 * @author yuuki.takezawa<yuuki.takezawa@comnect.jp.net>
31
 * @license http://opensource.org/licenses/MIT MIT
32
 */
33
class ClearCompiledCommand extends Command
34
{
35
    /**
36
     * @param SmartyFactory $smartyFactory
37
     */
38
    public function __construct(
39
        protected SmartyFactory $smartyFactory
40
    ) {
41
        parent::__construct();
42
    }
43
 
44
    /**
45
     * The console command name.
46
     *
47
     * @var string
48
     */
49
    protected $name = 'ytake:smarty-clear-compiled';
50
 
51
    /**
52
     * The console command description.
53
     *
54
     * @var string
55
     */
56
    protected $description = 'Remove the compiled Smarty files.';
57
 
58
    /**
59
     * Execute the console command.
60
     *
61
     * @return int
62
     */
63
    public function handle(): int
64
    {
65
        $removedFiles = $this->smartyFactory
66
            ->getSmarty()
67
            ->clearCompiledTemplate($this->option('file'), $this->option('compile_id'));
68
 
69
        if ($removedFiles > 0) {
70
            $this->info("Removed $removedFiles compiled Smarty file" . ($removedFiles > 1 ? 's' : '') . '.');
71
        }
72
 
73
        return 0;
74
    }
75
 
76
    /**
77
     * Get the console command options.
78
     *
79
     * @return array
80
     */
81
    protected function getOptions(): array
82
    {
83
        return [
84
            ['file', 'f', InputOption::VALUE_OPTIONAL, 'Specify file'],
85
            ['compile_id', 'compile', InputOption::VALUE_OPTIONAL, 'Specified compile_id'],
86
        ];
87
    }
88
}