1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/nnx-framework/form-comparator |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace Nnx\FormComparator\Comparator\Diff; |
7
|
|
|
|
8
|
|
|
use Nnx\FormComparator\Comparator\AbstractDiff; |
9
|
|
|
use Nnx\FormComparator\Comparator\DiffBuilder; |
10
|
|
|
use Zend\Form\ElementInterface; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class UpdateElement |
14
|
|
|
* |
15
|
|
|
* @package Nnx\FormComparator\Comparator\Diff |
16
|
|
|
*/ |
17
|
|
|
class UpdateElement extends AbstractDiff |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Старое значение |
21
|
|
|
* |
22
|
|
|
* @var mixed |
23
|
|
|
*/ |
24
|
|
|
private $sourceValue; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Новое значение |
28
|
|
|
* |
29
|
|
|
* @var mixed |
30
|
|
|
*/ |
31
|
|
|
private $targetValue; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Элемент который сравнивают |
35
|
|
|
* |
36
|
|
|
* @var ElementInterface |
37
|
|
|
*/ |
38
|
|
|
private $sourceElement; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Элемент с которым сравнивают |
42
|
|
|
* |
43
|
|
|
* @var ElementInterface |
44
|
|
|
*/ |
45
|
|
|
private $targetElement; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* UpdateElement constructor. |
49
|
|
|
* |
50
|
|
|
* @param DiffBuilder $diffBuilder |
51
|
|
|
*/ |
52
|
|
|
public function __construct(DiffBuilder $diffBuilder) |
53
|
|
|
{ |
54
|
|
|
$this->sourceValue = $diffBuilder->getSourceValue(); |
55
|
|
|
$this->targetValue = $diffBuilder->getTargetValue(); |
56
|
|
|
$this->sourceElement = $diffBuilder->getSourceElement(); |
57
|
|
|
$this->targetElement = $diffBuilder->getTargetElement(); |
58
|
|
|
|
59
|
|
|
parent::__construct($diffBuilder); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Элемент который сравнивают |
64
|
|
|
* |
65
|
|
|
* @return ElementInterface |
66
|
|
|
*/ |
67
|
|
|
public function getSourceElement() |
68
|
|
|
{ |
69
|
|
|
return $this->sourceElement; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Элемент с которым сравнивают |
74
|
|
|
* |
75
|
|
|
* @return ElementInterface |
76
|
|
|
*/ |
77
|
|
|
public function getTargetElement() |
78
|
|
|
{ |
79
|
|
|
return $this->targetElement; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return mixed |
85
|
|
|
*/ |
86
|
|
|
public function getSourceValue() |
87
|
|
|
{ |
88
|
|
|
return $this->sourceValue; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @param mixed $sourceValue |
93
|
|
|
* |
94
|
|
|
* @return $this |
95
|
|
|
*/ |
96
|
|
|
public function setSourceValue($sourceValue) |
97
|
|
|
{ |
98
|
|
|
$this->sourceValue = $sourceValue; |
99
|
|
|
|
100
|
|
|
return $this; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return mixed |
105
|
|
|
*/ |
106
|
|
|
public function getTargetValue() |
107
|
|
|
{ |
108
|
|
|
return $this->targetValue; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
/** |
112
|
|
|
* @param mixed $targetValue |
113
|
|
|
* |
114
|
|
|
* @return $this |
115
|
|
|
*/ |
116
|
|
|
public function setTargetValue($targetValue) |
117
|
|
|
{ |
118
|
|
|
$this->targetValue = $targetValue; |
119
|
|
|
|
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|