1 | <?php |
||
21 | class Arangodump extends Abstraction implements Executable |
||
22 | { |
||
23 | use OptionMasker; |
||
24 | |||
25 | /** |
||
26 | * Endpoint to connect to |
||
27 | * --server.endpoint <endpoint> |
||
28 | * |
||
29 | * @var string |
||
30 | */ |
||
31 | private $endpoint; |
||
32 | |||
33 | /** |
||
34 | * Username to connect with |
||
35 | * --server.username <username> |
||
36 | * |
||
37 | * @var string |
||
38 | */ |
||
39 | private $username; |
||
40 | |||
41 | /** |
||
42 | * Password to authenticate with |
||
43 | * --server.password <password> |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | private $password; |
||
48 | |||
49 | /** |
||
50 | * The database to backup |
||
51 | * --server.database <database> |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | private $database; |
||
56 | |||
57 | /** |
||
58 | * Whether the data should be dumped or not |
||
59 | * --dump-data |
||
60 | * |
||
61 | * @var boolean |
||
62 | */ |
||
63 | private $dumpData; |
||
64 | |||
65 | /** |
||
66 | * Include system collections |
||
67 | * --include-system-collections |
||
68 | * |
||
69 | * @var boolean |
||
70 | */ |
||
71 | private $includeSystemCollections; |
||
72 | |||
73 | /** |
||
74 | * Restrict the dump to these collections |
||
75 | * --collection |
||
76 | * |
||
77 | * @var array |
||
78 | */ |
||
79 | private $collections; |
||
80 | |||
81 | /** |
||
82 | * Do not ask for the username and password when connecting to the server. |
||
83 | * This does not control whether the server requires authentication. |
||
84 | * -- disable-authentication |
||
85 | * |
||
86 | * @var boolean |
||
87 | */ |
||
88 | private $disableAuthentication; |
||
89 | |||
90 | /** |
||
91 | * Directory to dump to. |
||
92 | * |
||
93 | * @var string |
||
94 | */ |
||
95 | private $dumpDir; |
||
96 | |||
97 | /** |
||
98 | * Constructor. |
||
99 | * |
||
100 | 14 | * @param string $path |
|
101 | */ |
||
102 | 14 | public function __construct(string $path = '') |
|
103 | 14 | { |
|
104 | 14 | $this->setup('arangodump', $path); |
|
105 | $this->setMaskCandidates(['password']); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Set target dump directory. |
||
110 | * |
||
111 | * @param string $path |
||
112 | 13 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
113 | */ |
||
114 | 13 | public function dumpTo(string $path) : Arangodump |
|
119 | |||
120 | /** |
||
121 | * Set user credentials. |
||
122 | * |
||
123 | * @param string $username |
||
124 | * @param string $password |
||
125 | 5 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
126 | */ |
||
127 | 5 | public function credentials(string $username = '', string $password = '') : Arangodump |
|
133 | |||
134 | /** |
||
135 | * Endpoint to use. |
||
136 | * |
||
137 | * @param string $endpoint |
||
138 | 4 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
139 | */ |
||
140 | 4 | public function useEndpoint(string $endpoint) : Arangodump |
|
145 | |||
146 | /** |
||
147 | * Database to dump. |
||
148 | * |
||
149 | * @param string $database |
||
150 | 4 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
151 | */ |
||
152 | 4 | public function dumpDatabase(string $database) : Arangodump |
|
157 | |||
158 | /** |
||
159 | * Collections to dump. |
||
160 | * |
||
161 | * @param array $collections |
||
162 | 4 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
163 | */ |
||
164 | 4 | public function dumpCollections(array $collections) : Arangodump |
|
169 | |||
170 | /** |
||
171 | * Disable authentication. |
||
172 | * |
||
173 | * @param boolean $bool |
||
174 | 4 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
175 | */ |
||
176 | 4 | public function disableAuthentication(bool $bool) : Arangodump |
|
181 | |||
182 | /** |
||
183 | * Dump system collections. |
||
184 | * |
||
185 | * @param boolean $bool |
||
186 | 4 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
187 | */ |
||
188 | 4 | public function includeSystemCollections(bool $bool) : Arangodump |
|
193 | |||
194 | /** |
||
195 | * Dump data as well. |
||
196 | * |
||
197 | * @param boolean $bool |
||
198 | 4 | * @return \phpbu\App\Cli\Executable\Arangodump |
|
199 | */ |
||
200 | 4 | public function dumpData(bool $bool) : Arangodump |
|
205 | |||
206 | /** |
||
207 | * Arangodump CommandLine generator. |
||
208 | * |
||
209 | * @return \SebastianFeldmann\Cli\CommandLine |
||
210 | 14 | * @throws \phpbu\App\Exception |
|
211 | */ |
||
212 | 14 | public function createCommandLine() : CommandLine |
|
237 | 13 | ||
238 | 1 | /** |
|
239 | 1 | * Handle command collection settings. |
|
240 | * |
||
241 | 13 | * @param \SebastianFeldmann\Cli\Command\Executable $cmd |
|
242 | 1 | */ |
|
243 | 1 | protected function handleCollections(Cmd $cmd) |
|
254 | |||
255 | /** |
||
256 | * Handle command data settings. |
||
257 | * |
||
258 | * @param \SebastianFeldmann\Cli\Command\Executable $cmd |
||
259 | */ |
||
260 | protected function handleDump(Cmd $cmd) |
||
267 | } |
||
268 |