|
18 | 18 | use umi\orm\metadata\field\relation\BelongsToRelationField; |
19 | 19 | use umi\orm\metadata\field\special\MaterializedPathField; |
20 | 20 | use umi\orm\object\IHierarchicObject; |
21 | | -use umi\orm\object\IObject; |
22 | | -use umi\orm\object\property\calculable\ICounterProperty; |
23 | 21 |
|
24 | 22 | /** |
25 | 23 | * Базовый класс иерархической коллекции |
26 | 24 | */ |
27 | 25 | abstract class BaseHierarchicCollection extends BaseCollection implements IHierarchicCollection |
28 | 26 | { |
29 | | - /** |
30 | | - * {@inheritdoc} |
31 | | - */ |
32 | | - public function delete(IObject $object) |
33 | | - { |
34 | | - parent::delete($object); |
35 | | - /** |
36 | | - * @var IHierarchicObject $object |
37 | | - */ |
38 | | - if (null != ($parent = $object->getParent())) { |
39 | | - /** |
40 | | - * @var ICounterProperty $childCount |
41 | | - */ |
42 | | - $childCount = $parent->getProperty(IHierarchicObject::FIELD_CHILD_COUNT); |
43 | | - $childCount->decrement(); |
44 | | - } |
45 | | - |
46 | | - return $this; |
47 | | - } |
48 | | - |
49 | 27 | /** |
50 | 28 | * {@inheritdoc} |
51 | 29 | */ |
@@ -92,14 +70,6 @@ public function getHierarchyLevelField() |
92 | 70 | return $this->getRequiredField(IHierarchicObject::FIELD_HIERARCHY_LEVEL); |
93 | 71 | } |
94 | 72 |
|
95 | | - /** |
96 | | - * {@inheritdoc} |
97 | | - */ |
98 | | - public function getHierarchyChildCountField() |
99 | | - { |
100 | | - return $this->getRequiredField(IHierarchicObject::FIELD_CHILD_COUNT); |
101 | | - } |
102 | | - |
103 | 73 | /** |
104 | 74 | * {@inheritdoc} |
105 | 75 | */ |
@@ -336,12 +306,6 @@ function () use ($object, $branch, $previousSibling) { |
336 | 306 | ]; |
337 | 307 |
|
338 | 308 | if ($object->getParent() !== $branch) { |
339 | | - if (null != ($parent = $object->getParent())) { |
340 | | - $builders[] = $this->buildUpdateChildCountQuery($parent, $this, -1); |
341 | | - } |
342 | | - if ($branch) { |
343 | | - $builders[] = $this->buildUpdateChildCountQuery($branch, $this, 1); |
344 | | - } |
345 | 309 | $builders[] = $this->buildUpdateHierarchicPropertiesQueryForMovedObject( |
346 | 310 | $object, |
347 | 311 | $this, |
@@ -551,47 +515,6 @@ protected function buildUpdateHierarchicPropertiesQueryForMovedObjectChildren( |
551 | 515 |
|
552 | 516 | } |
553 | 517 |
|
554 | | - /** |
555 | | - * Возвращает запрос на изменения количества детей. |
556 | | - * @param IHierarchicObject $object объект, у которого меняется количество детей |
557 | | - * @param IHierarchicCollection $collection коллекция, для которой формируется запрос |
558 | | - * @param int $childCountModifier число, на которое увеличивается или уменьшается количество детей |
559 | | - * @return IUpdateBuilder |
560 | | - */ |
561 | | - protected function buildUpdateChildCountQuery( |
562 | | - IHierarchicObject $object, |
563 | | - IHierarchicCollection $collection, |
564 | | - $childCountModifier |
565 | | - ) |
566 | | - { |
567 | | - |
568 | | - $dataSource = $collection |
569 | | - ->getMetadata() |
570 | | - ->getCollectionDataSource(); |
571 | | - $childCountField = $collection->getHierarchyChildCountField(); |
572 | | - $idField = $collection->getIdentifyField(); |
573 | | - |
574 | | - /** |
575 | | - * @var $update IUpdateBuilder |
576 | | - */ |
577 | | - $update = $dataSource->update(); |
578 | | - |
579 | | - $modifierExpression = $update |
580 | | - ->getConnection() |
581 | | - ->quoteIdentifier($childCountField->getColumnName()) . ' + (' . $childCountModifier . ')'; |
582 | | - $update |
583 | | - ->set($childCountField->getColumnName()) |
584 | | - ->bindExpression(':' . $childCountField->getColumnName(), $modifierExpression); |
585 | | - |
586 | | - $update |
587 | | - ->where() |
588 | | - ->expr($idField->getColumnName(), '=', ':' . $idField->getName()) |
589 | | - ->bindValue(':' . $idField->getName(), $object->getId(), $idField->getDataType()); |
590 | | - |
591 | | - return $update; |
592 | | - |
593 | | - } |
594 | | - |
595 | 518 | /** |
596 | 519 | * Возвращает запрос на изменение порядка в иерархии перемещаемого объекта |
597 | 520 | * @param IHierarchicObject $object перемещаемый объект |
|
0 commit comments