1 | <?php |
||
24 | class CompileShell extends Shell |
||
25 | // @codingStandardsIgnoreEnd |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * Instance of TwigView to be used to compile templates. |
||
30 | * |
||
31 | * @var TwigView |
||
32 | */ |
||
33 | protected $twigView; |
||
34 | |||
35 | /** |
||
36 | * Constructor. |
||
37 | * |
||
38 | * @param ConsoleIo $consoleIo An IO instance. |
||
39 | */ |
||
40 | 2 | public function __construct(ConsoleIo $consoleIo = null) |
|
41 | { |
||
42 | 2 | parent::__construct($consoleIo); |
|
43 | |||
44 | 2 | $this->twigView = new TwigView(); |
|
45 | 2 | } |
|
46 | |||
47 | /** |
||
48 | * Set TwigView. |
||
49 | * |
||
50 | * @param TwigView $twigView TwigView instance. |
||
51 | * |
||
52 | * @return void |
||
53 | */ |
||
54 | 1 | public function setTwigview(TwigView $twigView) |
|
58 | |||
59 | /** |
||
60 | * Compile all templates. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | // @codingStandardsIgnoreStart |
||
65 | 1 | public function all() |
|
66 | { |
||
67 | 1 | $this->out('<info>Compiling all templates</info>'); |
|
68 | |||
69 | 1 | foreach(Scanner::all() as $section => $templates) { |
|
70 | 1 | $this->out('<info>Compiling ' . $section . '\'s templates</info>'); |
|
71 | 1 | $this->walkIterator($templates); |
|
72 | } |
||
73 | 1 | } |
|
74 | // @codingStandardsIgnoreEnd |
||
75 | |||
76 | /** |
||
77 | * Compile only this plugin. |
||
78 | * |
||
79 | * @param string $plugin Plugin name. |
||
80 | * |
||
81 | * @return void |
||
82 | */ |
||
83 | 1 | public function plugin($plugin) |
|
84 | { |
||
85 | 1 | $this->out('<info>Compiling one ' . $plugin . '\'s templates</info>'); |
|
86 | 1 | $this->walkIterator(Scanner::plugin($plugin)); |
|
87 | } |
||
88 | |||
89 | /** |
||
90 | * Only compile one file. |
||
91 | * |
||
92 | * @param string $fileName File to compile. |
||
93 | * |
||
94 | * @return void |
||
95 | */ |
||
96 | 1 | public function file($fileName) |
|
101 | |||
102 | /** |
||
103 | * Walk over $iterator and compile all templates in it. |
||
104 | * |
||
105 | * @param mixed $iterator Iterator to walk over. |
||
106 | * |
||
107 | * @return void |
||
108 | */ |
||
109 | protected function walkIterator($iterator) |
||
110 | { |
||
111 | foreach ($iterator as $template) { |
||
112 | $this->compileTemplate($template); |
||
113 | } |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Compile a template. |
||
118 | * |
||
119 | * @param string $fileName Template to compile. |
||
120 | * |
||
121 | * @return void |
||
122 | */ |
||
123 | protected function compileTemplate($fileName) |
||
136 | |||
137 | /** |
||
138 | * Set options for this console. |
||
139 | * |
||
140 | * @return \Cake\Console\ConsoleOptionParser |
||
141 | */ |
||
142 | // @codingStandardsIgnoreStart |
||
143 | 1 | public function getOptionParser() |
|
174 | } |
||
175 |