1 | <?php |
||
24 | class Procedure implements ProcedureInterface |
||
25 | { |
||
26 | /** |
||
27 | * PhantomJS engine |
||
28 | * |
||
29 | * @var \JonnyW\PhantomJs\Engine |
||
30 | * @access protected |
||
31 | */ |
||
32 | protected $engine; |
||
33 | |||
34 | /** |
||
35 | * Parser instance. |
||
36 | * |
||
37 | * @var \JonnyW\PhantomJs\Parser\ParserInterface |
||
38 | * @access protected |
||
39 | */ |
||
40 | protected $parser; |
||
41 | |||
42 | /** |
||
43 | * Cache handler instance. |
||
44 | * |
||
45 | * @var \JonnyW\PhantomJs\Cache\CacheInterface |
||
46 | * @access protected |
||
47 | */ |
||
48 | protected $cacheHandler; |
||
49 | |||
50 | /** |
||
51 | * Template renderer. |
||
52 | * |
||
53 | * @var \JonnyW\PhantomJs\Template\TemplateRendererInterface |
||
54 | * @access protected |
||
55 | */ |
||
56 | protected $renderer; |
||
57 | |||
58 | /** |
||
59 | * Procedure template. |
||
60 | * |
||
61 | * @var string |
||
62 | * @access protected |
||
63 | */ |
||
64 | protected $template; |
||
65 | |||
66 | /** |
||
67 | * Internal constructor. |
||
68 | * |
||
69 | * @access public |
||
70 | * @param \JonnyW\PhantomJs\Engine $engine |
||
71 | * @param \JonnyW\PhantomJs\Parser\ParserInterface $parser |
||
72 | * @param \JonnyW\PhantomJs\Cache\CacheInterface $cacheHandler |
||
73 | * @param \JonnyW\PhantomJs\Template\TemplateRendererInterface $renderer |
||
74 | */ |
||
75 | 56 | public function __construct(Engine $engine, ParserInterface $parser, CacheInterface $cacheHandler, TemplateRendererInterface $renderer) |
|
82 | |||
83 | /** |
||
84 | * Run procedure. |
||
85 | * |
||
86 | * @access public |
||
87 | * @param \JonnyW\PhantomJs\Procedure\InputInterface $input |
||
88 | * @param \JonnyW\PhantomJs\Procedure\OutputInterface $output |
||
89 | * @throws \JonnyW\PhantomJs\Exception\ProcedureFailedException |
||
90 | * @throws \JonnyW\PhantomJs\Exception\NotWritableException |
||
91 | * @return void |
||
92 | */ |
||
93 | 49 | public function run(InputInterface $input, OutputInterface $output) |
|
141 | |||
142 | /** |
||
143 | * Set procedure template. |
||
144 | * |
||
145 | * @access public |
||
146 | * @param string $template |
||
147 | * @return \JonnyW\PhantomJs\Procedure\Procedure |
||
148 | */ |
||
149 | 51 | public function setTemplate($template) |
|
155 | |||
156 | /** |
||
157 | * Get procedure template. |
||
158 | * |
||
159 | * @access public |
||
160 | * @return string |
||
161 | */ |
||
162 | 52 | public function getTemplate() |
|
166 | |||
167 | /** |
||
168 | * Compile procedure. |
||
169 | * |
||
170 | * @access public |
||
171 | * @param \JonnyW\PhantomJs\Procedure\InputInterface $input |
||
172 | * @return void |
||
173 | */ |
||
174 | 50 | public function compile(InputInterface $input) |
|
178 | |||
179 | /** |
||
180 | * Write compiled procedure to cache. |
||
181 | * |
||
182 | * @access protected |
||
183 | * @param string $compiled |
||
184 | * @return string |
||
185 | */ |
||
186 | 49 | protected function write($compiled) |
|
190 | |||
191 | /** |
||
192 | * Remove procedure script cache. |
||
193 | * |
||
194 | * @access protected |
||
195 | * @param string $filePath |
||
196 | * @return void |
||
197 | */ |
||
198 | 48 | protected function remove($filePath) |
|
202 | } |
||
203 |