@@ 17-85 (lines=69) @@ | ||
14 | * |
|
15 | * @package Nnx\FormComparator\Comparator\Diff |
|
16 | */ |
|
17 | class InsertCollection extends AbstractDiffElement implements InsertedElementInterface |
|
18 | { |
|
19 | /** |
|
20 | * Добавленная коллекция |
|
21 | * |
|
22 | * @var Collection |
|
23 | */ |
|
24 | private $insertedCollection; |
|
25 | ||
26 | /** |
|
27 | * Элементы добавленной коллекции |
|
28 | * |
|
29 | * @var InsertElement[] |
|
30 | */ |
|
31 | private $insertedElements = []; |
|
32 | ||
33 | /** |
|
34 | * Возвращает элементы добавленной коллекции |
|
35 | * |
|
36 | * @return InsertElement[] |
|
37 | */ |
|
38 | public function getInsertedElements() |
|
39 | { |
|
40 | return $this->insertedElements; |
|
41 | } |
|
42 | /** |
|
43 | * Возвращает добавленную коллекцию (нет в форме которую сравнивают, но есть в форме с которой сравнивают) |
|
44 | * |
|
45 | * @return Collection |
|
46 | */ |
|
47 | public function getInsertedCollection() |
|
48 | { |
|
49 | return $this->insertedCollection; |
|
50 | } |
|
51 | ||
52 | /** |
|
53 | * InsertElement constructor. |
|
54 | * |
|
55 | * @param DiffElementBuilder $diffBuilder |
|
56 | */ |
|
57 | public function __construct(DiffElementBuilder $diffBuilder) |
|
58 | { |
|
59 | $this->insertedCollection = $diffBuilder->getTargetElement(); |
|
60 | ||
61 | parent::__construct($diffBuilder); |
|
62 | } |
|
63 | ||
64 | ||
65 | /** |
|
66 | * Определяет является ли diff для коллекции или для элемента формы |
|
67 | * |
|
68 | * @return bool |
|
69 | */ |
|
70 | public function isCollection() |
|
71 | { |
|
72 | return true; |
|
73 | } |
|
74 | ||
75 | ||
76 | /** |
|
77 | * Определяет какое действие было соверешенно с элементом (элемент был добавлен, изменен, удален) |
|
78 | * |
|
79 | * @return bool |
|
80 | */ |
|
81 | public function getMode() |
|
82 | { |
|
83 | return self::INSERT; |
|
84 | } |
|
85 | } |
|
86 |
@@ 16-66 (lines=51) @@ | ||
13 | * |
|
14 | * @package Nnx\FormComparator\Comparator\Diff |
|
15 | */ |
|
16 | class InsertElement extends AbstractDiffElement implements InsertedElementInterface |
|
17 | { |
|
18 | /** |
|
19 | * Возвращает добавленный элемент |
|
20 | * |
|
21 | * @var ElementInterface |
|
22 | */ |
|
23 | private $insertedElement; |
|
24 | ||
25 | /** |
|
26 | * Возвращает добавленный элемент (нет в форме которую сравнивают, но есть в форме с которой сравнивают) |
|
27 | * |
|
28 | * @return ElementInterface |
|
29 | */ |
|
30 | public function getInsertedElement() |
|
31 | { |
|
32 | return $this->insertedElement; |
|
33 | } |
|
34 | ||
35 | /** |
|
36 | * InsertElement constructor. |
|
37 | * |
|
38 | * @param DiffElementBuilder $diffBuilder |
|
39 | */ |
|
40 | public function __construct(DiffElementBuilder $diffBuilder) |
|
41 | { |
|
42 | $this->insertedElement = $diffBuilder->getTargetElement(); |
|
43 | ||
44 | parent::__construct($diffBuilder); |
|
45 | } |
|
46 | ||
47 | /** |
|
48 | * Определяет является ли diff для коллекции или для элемента формы |
|
49 | * |
|
50 | * @return bool |
|
51 | */ |
|
52 | public function isCollection() |
|
53 | { |
|
54 | return false; |
|
55 | } |
|
56 | ||
57 | /** |
|
58 | * Определяет какое действие было соверешенно с элементом (элемент был добавлен, изменен, удален) |
|
59 | * |
|
60 | * @return bool |
|
61 | */ |
|
62 | public function getMode() |
|
63 | { |
|
64 | return self::INSERT; |
|
65 | } |
|
66 | } |
|
67 |