1 | <?php |
||
32 | class OcrProvider extends AbstractProvider { |
||
33 | |||
34 | use StringHostnameTrait; |
||
35 | use StringPasswordTrait; |
||
36 | use StringUsernameTrait; |
||
37 | |||
38 | /** |
||
39 | * FTP client. |
||
40 | * |
||
41 | * @var FtpClient |
||
42 | */ |
||
43 | private $ftpClient; |
||
44 | |||
45 | /** |
||
46 | * Local directory "after". |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | private $localDirectoryAfter; |
||
51 | |||
52 | /** |
||
53 | * Local directory "before". |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | private $localDirectoryBefore; |
||
58 | |||
59 | /** |
||
60 | * Local directory "error". |
||
61 | * |
||
62 | * @var string |
||
63 | */ |
||
64 | private $localDirectoryError; |
||
65 | |||
66 | /** |
||
67 | * Remote directory "after". |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | private $remoteDirectoryAfter; |
||
72 | |||
73 | /** |
||
74 | * Remote directory "before". |
||
75 | * |
||
76 | * @var string |
||
77 | */ |
||
78 | private $remoteDirectoryBefore; |
||
79 | |||
80 | /** |
||
81 | * Remote directory "error". |
||
82 | * |
||
83 | * @var string |
||
84 | */ |
||
85 | private $remoteDirectoryError; |
||
86 | |||
87 | /** |
||
88 | * Constructor. |
||
89 | * |
||
90 | * @param LoggerInterface $logger The logger. |
||
91 | */ |
||
92 | public function __construct(LoggerInterface $logger) { |
||
98 | |||
99 | /** |
||
100 | * Destructor. |
||
101 | * |
||
102 | * @throws FtpException Throws a FTP exception if an error occurs. |
||
103 | */ |
||
104 | public function __destruct() { |
||
113 | |||
114 | /** |
||
115 | * Build the file paths. |
||
116 | * |
||
117 | * @param IOFile $file The file. |
||
118 | * @return array Returns the file paths. |
||
119 | */ |
||
120 | protected function buildFilePaths(IOFile $file) { |
||
137 | |||
138 | /** |
||
139 | * Delete the files. |
||
140 | * |
||
141 | * @param IOFile $file The I/O file. |
||
142 | * @return void |
||
143 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
144 | */ |
||
145 | public function deleteFiles(IOFile $file) { |
||
177 | |||
178 | /** |
||
179 | * Download the files. |
||
180 | * |
||
181 | * @param IOFile $file The I/O file. |
||
182 | * @return bool Returns true in case of success, false otherwise. |
||
183 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
184 | */ |
||
185 | public function downloadFiles(IOFile $file) { |
||
216 | |||
217 | /** |
||
218 | * Get the FTP client. |
||
219 | * |
||
220 | * @return FtpClient Returns the FTP client. |
||
221 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
222 | */ |
||
223 | public function getFtpClient() { |
||
244 | |||
245 | /** |
||
246 | * Get the local directory "after". |
||
247 | * |
||
248 | * @return string Returns the local directory "after". |
||
249 | */ |
||
250 | public function getLocalDirectoryAfter() { |
||
253 | |||
254 | /** |
||
255 | * Get the local directory "before". |
||
256 | * |
||
257 | * @return string Returns the local directory "before" |
||
258 | */ |
||
259 | public function getLocalDirectoryBefore() { |
||
262 | |||
263 | /** |
||
264 | * Get the local directory "error". |
||
265 | * |
||
266 | * @return string Returns the local directory "error". |
||
267 | */ |
||
268 | public function getLocalDirectoryError() { |
||
271 | |||
272 | /** |
||
273 | * Ge the remote directory "after". |
||
274 | * |
||
275 | * @return string Returns the remote directory "after". |
||
276 | */ |
||
277 | public function getRemoteDirectoryAfter() { |
||
280 | |||
281 | /** |
||
282 | * Get the remote directory "before". |
||
283 | * |
||
284 | * @return string Returns the remote directory "before". |
||
285 | */ |
||
286 | public function getRemoteDirectoryBefore() { |
||
289 | |||
290 | /** |
||
291 | * Get the remote directory "error". |
||
292 | * |
||
293 | * @return string Returns the remote directory "error". |
||
294 | */ |
||
295 | public function getRemoteDirectoryError() { |
||
298 | |||
299 | /** |
||
300 | * Scan a file. |
||
301 | * |
||
302 | * @param IOFile $file The I/O file. |
||
303 | * @param int $retry The retry count. |
||
304 | * @param int $wait The waiting time (in seconds) between retries. |
||
305 | * @return bool Returns true in case of success, false otherwise. |
||
306 | * @throws FtpException Throws an FTP exception in case of success, false otherwise. |
||
307 | */ |
||
308 | public function scanFile(IOFile $file, $retry = 30, $wait = 5) { |
||
335 | |||
336 | /** |
||
337 | * Set the local directory "after". |
||
338 | * |
||
339 | * @param string $localDirectoryAfter The local directory "after". |
||
340 | * @return OcrProvider Returns this OCR provider. |
||
341 | */ |
||
342 | public function setLocalDirectoryAfter($localDirectoryAfter) { |
||
346 | |||
347 | /** |
||
348 | * Set the local directory "before". |
||
349 | * |
||
350 | * @param string $localDirectoryBefore The local directory "before" |
||
351 | * @return OcrProvider Returns this OCR provider. |
||
352 | */ |
||
353 | public function setLocalDirectoryBefore($localDirectoryBefore) { |
||
357 | |||
358 | /** |
||
359 | * Set the local directory "error". |
||
360 | * |
||
361 | * @param string $localDirectoryError The local directory "error". |
||
362 | * @return OcrProvider Returns this OCR provider. |
||
363 | */ |
||
364 | public function setLocalDirectoryError($localDirectoryError) { |
||
368 | |||
369 | /** |
||
370 | * Set the remote directory "after". |
||
371 | * |
||
372 | * @param string $remoteDirectoryAfter The remote directory "after". |
||
373 | * @return OcrProvider Returns this OCR provider. |
||
374 | */ |
||
375 | public function setRemoteDirectoryAfter($remoteDirectoryAfter) { |
||
379 | |||
380 | /** |
||
381 | * Set the remote directory "before". |
||
382 | * |
||
383 | * @param string $remoteDirectoryBefore The remote directory "before". |
||
384 | * @return OcrProvider Returns this OCR provider. |
||
385 | */ |
||
386 | public function setRemoteDirectoryBefore($remoteDirectoryBefore) { |
||
390 | |||
391 | /** |
||
392 | * Set the remote directory "error". |
||
393 | * |
||
394 | * @param string $remoteDirectoryError The remote directory "error". |
||
395 | * @return OcrProvider Returns this OCR provider. |
||
396 | */ |
||
397 | public function setRemoteDirectoryError($remoteDirectoryError) { |
||
401 | |||
402 | /** |
||
403 | * Upload a file. |
||
404 | * |
||
405 | * @param IOFile $file The I/O file. |
||
406 | * @return void |
||
407 | * @throws FtpException Throws an FTP exception if an error occurs. |
||
408 | */ |
||
409 | public function uploadFile(IOFile $file) { |
||
416 | } |