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-2016 Yuuki Takezawa |
16
|
|
|
* |
17
|
|
|
*/ |
18
|
|
|
namespace Ytake\LaravelSmarty\Console; |
19
|
|
|
|
20
|
|
|
use Illuminate\Console\Command; |
21
|
|
|
use Symfony\Component\Console\Input\InputOption; |
22
|
|
|
use Ytake\LaravelSmarty\SmartyFactory; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class ClearCompiledCommand |
26
|
|
|
* |
27
|
|
|
* @author yuuki.takezawa<[email protected]> |
28
|
|
|
* @license http://opensource.org/licenses/MIT MIT |
29
|
|
|
*/ |
30
|
|
|
class ClearCompiledCommand extends Command |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* The console command name. |
34
|
|
|
* |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
protected $name = 'ytake:smarty-clear-compiled'; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* The console command description. |
41
|
|
|
* |
42
|
|
|
* @var string |
43
|
|
|
*/ |
44
|
|
|
protected $description = 'Remove the compiled smarty file'; |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Execute the console command. |
48
|
|
|
* |
49
|
|
|
* @param \Ytake\LaravelSmarty\SmartyFactory $smartyFactory |
50
|
|
|
* @return int |
51
|
|
|
*/ |
52
|
|
|
public function fire(SmartyFactory $smartyFactory) |
53
|
|
|
{ |
54
|
|
|
$removedFiles = $smartyFactory->getSmarty() |
55
|
|
|
->clearCompiledTemplate($this->option('file'), $this->option('compile_id')); |
56
|
|
|
|
57
|
|
|
$this->info("removed $removedFiles files."); |
58
|
|
|
return 0; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the console command options. |
63
|
|
|
* |
64
|
|
|
* @return array |
65
|
|
|
*/ |
66
|
|
|
protected function getOptions() |
67
|
|
|
{ |
68
|
|
|
return [ |
69
|
|
|
['file', 'f', InputOption::VALUE_OPTIONAL, 'specify file'], |
70
|
|
|
['compile_id', 'compile', InputOption::VALUE_OPTIONAL, 'specified compile_id'], |
71
|
|
|
]; |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|