|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Yandex PHP Library |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright NIX Solutions Ltd. |
|
6
|
|
|
* @link https://github.com/nixsolutions/yandex-php-library |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
/** |
|
10
|
|
|
* @namespace |
|
11
|
|
|
*/ |
|
12
|
|
|
namespace Yandex\DataSync\Models\Database; |
|
13
|
|
|
|
|
14
|
|
|
use Yandex\Common\Model; |
|
15
|
|
|
use Yandex\DataSync\Models\Database\Delta\Records; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Class Delta |
|
19
|
|
|
* |
|
20
|
|
|
* @category Yandex |
|
21
|
|
|
* @package DataSync |
|
22
|
|
|
* |
|
23
|
|
|
* @author Alexander Khaylo <[email protected]> |
|
24
|
|
|
* @created 02.03.16 11:29 |
|
25
|
|
|
*/ |
|
26
|
|
|
class Delta extends Model |
|
27
|
|
|
{ |
|
28
|
|
|
protected $propNameMap = [ |
|
29
|
|
|
'delta_id' => 'deltaId', |
|
30
|
|
|
'base_revision' => 'baseRevision' |
|
31
|
|
|
]; |
|
32
|
|
|
|
|
33
|
|
|
protected $mappingClasses = [ |
|
34
|
|
|
'changes' => 'Yandex\DataSync\Models\Database\Delta\Records', |
|
35
|
|
|
]; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Explanatory comment on the change. |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $deltaId; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var int |
|
46
|
|
|
*/ |
|
47
|
|
|
protected $baseRevision; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Changes in individual database records. |
|
51
|
|
|
* |
|
52
|
|
|
* @var Records |
|
53
|
|
|
*/ |
|
54
|
|
|
protected $changes; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @return Records |
|
58
|
|
|
*/ |
|
59
|
1 |
|
public function getChanges() |
|
60
|
|
|
{ |
|
61
|
1 |
|
return $this->changes; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param Records|array $changes |
|
66
|
|
|
* |
|
67
|
|
|
* @return $this |
|
68
|
|
|
*/ |
|
69
|
3 |
|
public function setChanges($changes) |
|
70
|
|
|
{ |
|
71
|
3 |
|
if ($changes instanceof Records) { |
|
72
|
1 |
|
$this->changes = $changes; |
|
73
|
1 |
|
} else { |
|
74
|
3 |
|
if (is_array($changes)) { |
|
75
|
3 |
|
$changes = new Records($changes); |
|
76
|
3 |
|
$this->changes = $changes; |
|
77
|
3 |
|
} |
|
78
|
|
|
} |
|
79
|
3 |
|
return $this; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
1 |
|
public function getDeltaId() |
|
86
|
|
|
{ |
|
87
|
1 |
|
return $this->deltaId; |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @param $deltaId |
|
92
|
|
|
* |
|
93
|
|
|
* @return $this |
|
94
|
|
|
*/ |
|
95
|
4 |
|
public function setDeltaId($deltaId) |
|
96
|
|
|
{ |
|
97
|
4 |
|
$this->deltaId = $deltaId; |
|
98
|
4 |
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @return int |
|
103
|
|
|
*/ |
|
104
|
1 |
|
public function getBaseRevision() |
|
105
|
|
|
{ |
|
106
|
1 |
|
return $this->baseRevision; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* @param int $baseRevision |
|
111
|
|
|
*/ |
|
112
|
1 |
|
public function setBaseRevision($baseRevision) |
|
113
|
|
|
{ |
|
114
|
1 |
|
$this->baseRevision = $baseRevision; |
|
115
|
1 |
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|