1 | <?php |
||
32 | class OcrProvider { |
||
33 | |||
34 | use LoggerAwareTrait; |
||
35 | use StringHostnameTrait; |
||
36 | use StringPasswordTrait; |
||
37 | use StringUsernameTrait; |
||
38 | |||
39 | /** |
||
40 | * FTP client. |
||
41 | * |
||
42 | * @var FtpClient |
||
43 | */ |
||
44 | private $ftpClient; |
||
45 | |||
46 | /** |
||
47 | * Local directory "after". |
||
48 | * |
||
49 | * @var string |
||
50 | */ |
||
51 | private $localDirectoryAfter; |
||
52 | |||
53 | /** |
||
54 | * Local directory "before". |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | private $localDirectoryBefore; |
||
59 | |||
60 | /** |
||
61 | * Local directory "error". |
||
62 | * |
||
63 | * @var string |
||
64 | */ |
||
65 | private $localDirectoryError; |
||
66 | |||
67 | /** |
||
68 | * Remote directory "after". |
||
69 | * |
||
70 | * @var string |
||
71 | */ |
||
72 | private $remoteDirectoryAfter; |
||
73 | |||
74 | /** |
||
75 | * Remote directory "before". |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | private $remoteDirectoryBefore; |
||
80 | |||
81 | /** |
||
82 | * Remote directory "error". |
||
83 | * |
||
84 | * @var string |
||
85 | */ |
||
86 | private $remoteDirectoryError; |
||
87 | |||
88 | /** |
||
89 | * Constructor. |
||
90 | * |
||
91 | * @param LoggerInterface $logger The logger. |
||
92 | */ |
||
93 | public function __construct(LoggerInterface $logger) { |
||
99 | |||
100 | /** |
||
101 | * Destructor. |
||
102 | * |
||
103 | * @throws FtpException Throws a FTP exception if an error occurs. |
||
104 | */ |
||
105 | public function __destruct() { |
||
114 | |||
115 | /** |
||
116 | * Build the file paths. |
||
117 | * |
||
118 | * @param IOFile $file The file. |
||
119 | * @return array Returns the file paths. |
||
120 | */ |
||
121 | protected function buildFilePaths(IOFile $file) { |
||
136 | |||
137 | /** |
||
138 | * Delete the files. |
||
139 | * |
||
140 | * @param IOFile $file The I/O file. |
||
141 | * @return void |
||
142 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
143 | */ |
||
144 | public function deleteFiles(IOFile $file) { |
||
176 | |||
177 | /** |
||
178 | * Download the files. |
||
179 | * |
||
180 | * @param IOFile $file The I/O file. |
||
181 | * @return bool Returns true in case of success, false otherwise. |
||
182 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
183 | */ |
||
184 | public function downloadFiles(IOFile $file) { |
||
214 | |||
215 | /** |
||
216 | * Get the FTP client. |
||
217 | * |
||
218 | * @return FtpClient Returns the FTP client. |
||
219 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
220 | */ |
||
221 | public function getFtpClient() { |
||
242 | |||
243 | /** |
||
244 | * Get the local directory "after". |
||
245 | * |
||
246 | * @return string Returns the local directory "after". |
||
247 | */ |
||
248 | public function getLocalDirectoryAfter() { |
||
251 | |||
252 | /** |
||
253 | * Get the local directory "before". |
||
254 | * |
||
255 | * @return string Returns the local directory "before" |
||
256 | */ |
||
257 | public function getLocalDirectoryBefore() { |
||
260 | |||
261 | /** |
||
262 | * Get the local directory "error". |
||
263 | * |
||
264 | * @return string Returns the local directory "error". |
||
265 | */ |
||
266 | public function getLocalDirectoryError() { |
||
269 | |||
270 | /** |
||
271 | * Get the logger. |
||
272 | * |
||
273 | * @return LoggerInterface Returns the logger. |
||
274 | */ |
||
275 | public function getLogger() { |
||
278 | |||
279 | /** |
||
280 | * Ge the remote directory "after". |
||
281 | * |
||
282 | * @return string Returns the remote directory "after". |
||
283 | */ |
||
284 | public function getRemoteDirectoryAfter() { |
||
287 | |||
288 | /** |
||
289 | * Get the remote directory "before". |
||
290 | * |
||
291 | * @return string Returns the remote directory "before". |
||
292 | */ |
||
293 | public function getRemoteDirectoryBefore() { |
||
296 | |||
297 | /** |
||
298 | * Get the remote directory "error". |
||
299 | * |
||
300 | * @return string Returns the remote directory "error". |
||
301 | */ |
||
302 | public function getRemoteDirectoryError() { |
||
305 | |||
306 | /** |
||
307 | * Scan a file. |
||
308 | * |
||
309 | * @param IOFile $file The I/O file. |
||
310 | * @param int $retry The retry count. |
||
311 | * @param int $wait The waiting time (in seconds) between retries. |
||
312 | * @return bool Returns true in case of success, false otherwise. |
||
313 | * @throws FtpException Throws an FTP exception in case of success, false otherwise. |
||
314 | */ |
||
315 | public function scanFile(IOFile $file, $retry = 30, $wait = 5) { |
||
342 | |||
343 | /** |
||
344 | * Set the local directory "after". |
||
345 | * |
||
346 | * @param string $localDirectoryAfter The local directory "after". |
||
347 | * @return OcrProvider Returns this OCR provider. |
||
348 | */ |
||
349 | public function setLocalDirectoryAfter($localDirectoryAfter) { |
||
353 | |||
354 | /** |
||
355 | * Set the local directory "before". |
||
356 | * |
||
357 | * @param string $localDirectoryBefore The local directory "before" |
||
358 | * @return OcrProvider Returns this OCR provider. |
||
359 | */ |
||
360 | public function setLocalDirectoryBefore($localDirectoryBefore) { |
||
364 | |||
365 | /** |
||
366 | * Set the local directory "error". |
||
367 | * |
||
368 | * @param string $localDirectoryError The local directory "error". |
||
369 | * @return OcrProvider Returns this OCR provider. |
||
370 | */ |
||
371 | public function setLocalDirectoryError($localDirectoryError) { |
||
375 | |||
376 | /** |
||
377 | * Set the remote directory "after". |
||
378 | * |
||
379 | * @param string $remoteDirectoryAfter The remote directory "after". |
||
380 | * @return OcrProvider Returns this OCR provider. |
||
381 | */ |
||
382 | public function setRemoteDirectoryAfter($remoteDirectoryAfter) { |
||
386 | |||
387 | /** |
||
388 | * Set the remote directory "before". |
||
389 | * |
||
390 | * @param string $remoteDirectoryBefore The remote directory "before". |
||
391 | * @return OcrProvider Returns this OCR provider. |
||
392 | */ |
||
393 | public function setRemoteDirectoryBefore($remoteDirectoryBefore) { |
||
397 | |||
398 | /** |
||
399 | * Set the remote directory "error". |
||
400 | * |
||
401 | * @param string $remoteDirectoryError The remote directory "error". |
||
402 | * @return OcrProvider Returns this OCR provider. |
||
403 | */ |
||
404 | public function setRemoteDirectoryError($remoteDirectoryError) { |
||
408 | |||
409 | /** |
||
410 | * Upload a file. |
||
411 | * |
||
412 | * @param IOFile $file The I/O file. |
||
413 | * @return void |
||
414 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
415 | */ |
||
416 | public function uploadFile(IOFile $file) { |
||
423 | } |