1 | <?php |
||
22 | class Ftp extends Xtp implements Simulator |
||
23 | { |
||
24 | use Clearable; |
||
25 | |||
26 | /** |
||
27 | * FlySystem instance |
||
28 | * |
||
29 | * @var Filesystem |
||
30 | */ |
||
31 | protected $flySystem; |
||
32 | |||
33 | /** |
||
34 | * Determine should ftp connects via passive mode. |
||
35 | * |
||
36 | * @var bool |
||
37 | */ |
||
38 | protected $passiveMode; |
||
39 | |||
40 | /** |
||
41 | * Setup the Ftp sync. |
||
42 | * |
||
43 | * @param array $config |
||
44 | * @throws \phpbu\App\Backup\Sync\Exception |
||
45 | * @throws \phpbu\App\Exception |
||
46 | */ |
||
47 | 5 | public function setup(array $config) |
|
48 | { |
||
49 | 5 | parent::setup($config); |
|
50 | |||
51 | 2 | $this->passiveMode = Str::toBoolean(Arr::getValue($config, 'passive_mode', ''), false); |
|
52 | 2 | $this->setUpClearable($config); |
|
53 | 2 | } |
|
54 | |||
55 | /** |
||
56 | * Check for required loaded libraries or extensions. |
||
57 | * |
||
58 | * @throws \phpbu\App\Backup\Sync\Exception |
||
59 | */ |
||
60 | 5 | protected function checkRequirements() |
|
61 | { |
||
62 | 5 | if (!function_exists('ftp_connect')) { |
|
63 | throw new Exception('ftp functions not enabled'); |
||
64 | } |
||
65 | 5 | } |
|
66 | |||
67 | /** |
||
68 | * Return implemented (*)TP protocol name. |
||
69 | * |
||
70 | * @return string |
||
71 | */ |
||
72 | 1 | protected function getProtocolName() |
|
73 | { |
||
74 | 1 | return 'FTP'; |
|
75 | } |
||
76 | |||
77 | /** |
||
78 | * (non-PHPDoc) |
||
79 | * |
||
80 | * @see \phpbu\App\Backup\Sync::sync() |
||
81 | * @param \phpbu\App\Backup\Target $target |
||
82 | * @param \phpbu\App\Result $result |
||
83 | * @throws \phpbu\App\Backup\Sync\Exception |
||
84 | */ |
||
85 | public function sync(Target $target, Result $result) |
||
116 | |||
117 | /** |
||
118 | * Execute the remote clean up if needed |
||
119 | * |
||
120 | * @param \phpbu\App\Backup\Target $target |
||
121 | * @param \phpbu\App\Result $result |
||
122 | */ |
||
123 | public function cleanup(Target $target, Result $result) |
||
132 | } |
||
133 |