1 | <?php |
||
31 | class ClearCompiledCommand extends Command |
||
32 | { |
||
33 | /** @var SmartyFactory */ |
||
34 | protected $smartyFactory; |
||
35 | |||
36 | /** |
||
37 | * @param SmartyFactory $smartyFactory |
||
38 | */ |
||
39 | public function __construct(SmartyFactory $smartyFactory) |
||
44 | |||
45 | /** |
||
46 | * The console command name. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | protected $name = 'ytake:smarty-clear-compiled'; |
||
51 | |||
52 | /** |
||
53 | * The console command description. |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $description = 'Remove the compiled Smarty files.'; |
||
58 | |||
59 | /** |
||
60 | * Execute the console command. |
||
61 | * |
||
62 | * @return int |
||
63 | */ |
||
64 | public function handle() |
||
65 | { |
||
66 | $removedFiles = $this->smartyFactory |
||
67 | ->getSmarty() |
||
68 | ->clearCompiledTemplate($this->option('file'), $this->option('compile_id')); |
||
69 | |||
70 | if ($removedFiles > 0) { |
||
71 | $this->info("Removed $removedFiles compiled Smarty file" . ($removedFiles > 1 ? 's' : '') . '.'); |
||
72 | } |
||
73 | |||
74 | return 0; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * Get the console command options. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | protected function getOptions() |
||
89 | } |
||
90 |