-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathDestination.php
More file actions
58 lines (51 loc) · 1.61 KB
/
Destination.php
File metadata and controls
58 lines (51 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Utopia\Migration;
abstract class Destination extends Target
{
/**
* Source
*/
protected Source $source;
public function getSource(): Source
{
return $this->source;
}
public function setSource(Source $source): self
{
$this->source = $source;
return $this;
}
/**
* Transfer Resources to Destination from Source callback
*
* @param array<string> $resources Resources to transfer
* @param callable(array<Resource>): void $callback to run after transfer
* @param string $rootResourceId Root resource ID. If set, only this root resource is transferred.
* @param string $rootResourceType Resource type for $rootResourceId.
* @param string $rootResourceChildId Optional child filter under the root resource. For database roots, this is the collection/table ID.
*/
public function run(
array $resources,
callable $callback,
string $rootResourceId = '',
string $rootResourceType = '',
string $rootResourceChildId = '',
): void {
$this->source->run(
$resources,
function (array $resources) use ($callback) {
$this->import($resources, $callback);
},
$rootResourceId,
$rootResourceType,
$rootResourceChildId,
);
}
/**
* Import Resources
*
* @param Resource[] $resources Resources to import
* @param callable $callback Callback to run after import
*/
abstract protected function import(array $resources, callable $callback): void;
}