1 | <?php |
||
36 | class ImportCommand extends ImportCommandAbstract |
||
37 | { |
||
38 | /** |
||
39 | * @var HttpClient |
||
40 | */ |
||
41 | private $client; |
||
42 | |||
43 | /** |
||
44 | * @var FrontMatter |
||
45 | */ |
||
46 | private $frontMatter; |
||
47 | |||
48 | /** |
||
49 | * @var Parser |
||
50 | */ |
||
51 | private $parser; |
||
52 | |||
53 | /** |
||
54 | * @var VarCloner |
||
55 | */ |
||
56 | private $cloner; |
||
57 | |||
58 | /** |
||
59 | * @var Dumper |
||
60 | */ |
||
61 | private $dumper; |
||
62 | |||
63 | /** |
||
64 | * @param HttpClient $client Grv HttpClient guzzle http client |
||
65 | * @param Finder $finder symfony/finder instance |
||
66 | * @param FrontMatter $frontMatter frontmatter parser |
||
67 | * @param Parser $parser yaml/json parser |
||
68 | * @param VarCloner $cloner var cloner for dumping reponses |
||
69 | * @param Dumper $dumper dumper for outputing responses |
||
70 | */ |
||
71 | 5 | public function __construct( |
|
88 | |||
89 | /** |
||
90 | * Configures the current command. |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | 5 | protected function configure() |
|
130 | |||
131 | /** |
||
132 | * Executes the current command. |
||
133 | * |
||
134 | * @param Finder $finder Finder |
||
135 | * @param InputInterface $input User input on console |
||
136 | * @param OutputInterface $output Output of the command |
||
137 | * |
||
138 | * @return void |
||
139 | */ |
||
140 | 5 | protected function doImport(Finder $finder, InputInterface $input, OutputInterface $output) |
|
152 | |||
153 | /** |
||
154 | * @param Finder $finder finder primmed with files to import |
||
155 | * @param OutputInterface $output output interfac |
||
156 | * @param string $host host to import into |
||
157 | * @param string $rewriteHost string to replace with value from $rewriteTo during loading |
||
158 | * @param string $rewriteTo string to replace value from $rewriteHost with during loading |
||
159 | * @param boolean $sync send requests syncronously |
||
160 | * |
||
161 | * @return void |
||
162 | * |
||
163 | * @throws MissingTargetException |
||
164 | */ |
||
165 | 5 | protected function importPaths( |
|
203 | |||
204 | /** |
||
205 | * @param string $targetUrl target url to import resource into |
||
206 | * @param string $file path to file being loaded |
||
207 | * @param OutputInterface $output output of the command |
||
208 | * @param Document $doc document to load |
||
209 | * @param string $host host to import into |
||
210 | * @param string $rewriteHost string to replace with value from $host during loading |
||
211 | * @param string $rewriteTo string to replace value from $rewriteHost with during loading |
||
212 | * @param boolean $sync send requests syncronously |
||
213 | * |
||
214 | * @return Promise\Promise|null |
||
215 | */ |
||
216 | protected function importResource( |
||
297 | |||
298 | /** |
||
299 | * parse contents of a file depending on type |
||
300 | * |
||
301 | * @param string $content contents part of file |
||
302 | * @param string $file full path to file |
||
303 | * |
||
304 | * @return mixed |
||
305 | */ |
||
306 | protected function parseContent($content, $file) |
||
307 | { |
||
308 | 4 | if (substr($file, -5) == '.json') { |
|
309 | 3 | $data = json_decode($content); |
|
310 | 3 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
311 | throw new JsonParseException( |
||
312 | sprintf( |
||
313 | 3 | '%s in %s', |
|
314 | json_last_error_msg(), |
||
315 | $file |
||
316 | ) |
||
317 | ); |
||
318 | } |
||
319 | 1 | } elseif (substr($file, -4) == '.yml') { |
|
320 | 1 | $data = $this->parser->parse($content); |
|
321 | } else { |
||
322 | throw new UnknownFileTypeException($file); |
||
323 | } |
||
324 | |||
325 | 4 | return $data; |
|
326 | } |
||
327 | |||
328 | /** |
||
329 | * Checks if file exists and return qualified fileName location |
||
330 | * |
||
331 | * @param Document $doc Data source for import data |
||
332 | * @param string $originFile Original full filename used toimport |
||
333 | * @return bool|mixed |
||
334 | */ |
||
335 | private function validateUploadFile(Document $doc, $originFile) |
||
352 | } |
||
353 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.