Skip to content

Commit 2e4f8be

Browse files
author
Daria Prusova
committed
[orm] remove childCount field
1 parent d791c82 commit 2e4f8be

33 files changed

Lines changed: 7 additions & 460 deletions

library/orm/collection/BaseHierarchicCollection.php

Lines changed: 0 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,12 @@
1818
use umi\orm\metadata\field\relation\BelongsToRelationField;
1919
use umi\orm\metadata\field\special\MaterializedPathField;
2020
use umi\orm\object\IHierarchicObject;
21-
use umi\orm\object\IObject;
22-
use umi\orm\object\property\calculable\ICounterProperty;
2321

2422
/**
2523
* Базовый класс иерархической коллекции
2624
*/
2725
abstract class BaseHierarchicCollection extends BaseCollection implements IHierarchicCollection
2826
{
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-
4927
/**
5028
* {@inheritdoc}
5129
*/
@@ -92,14 +70,6 @@ public function getHierarchyLevelField()
9270
return $this->getRequiredField(IHierarchicObject::FIELD_HIERARCHY_LEVEL);
9371
}
9472

95-
/**
96-
* {@inheritdoc}
97-
*/
98-
public function getHierarchyChildCountField()
99-
{
100-
return $this->getRequiredField(IHierarchicObject::FIELD_CHILD_COUNT);
101-
}
102-
10373
/**
10474
* {@inheritdoc}
10575
*/
@@ -336,12 +306,6 @@ function () use ($object, $branch, $previousSibling) {
336306
];
337307

338308
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-
}
345309
$builders[] = $this->buildUpdateHierarchicPropertiesQueryForMovedObject(
346310
$object,
347311
$this,
@@ -551,47 +515,6 @@ protected function buildUpdateHierarchicPropertiesQueryForMovedObjectChildren(
551515

552516
}
553517

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-
595518
/**
596519
* Возвращает запрос на изменение порядка в иерархии перемещаемого объекта
597520
* @param IHierarchicObject $object перемещаемый объект

library/orm/collection/CommonHierarchy.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,6 @@ protected function persistMovedObjects(
8787
}
8888

8989
if ($object->getParent() !== $branch) {
90-
91-
if (null != ($parent = $object->getParent())) {
92-
$builders[] = $this->buildUpdateChildCountQuery($parent, $this, -1);
93-
$builders[] = $this->buildUpdateChildCountQuery($parent, $parent->getCollection(), -1);
94-
}
95-
if ($branch) {
96-
$builders[] = $this->buildUpdateChildCountQuery($branch, $this, 1);
97-
$builders[] = $this->buildUpdateChildCountQuery($branch, $branch->getCollection(), 1);
98-
}
9990
$builders[] = $this->buildUpdateHierarchicPropertiesQueryForMovedObject($object, $this, $branch);
10091
$builders[] = $this->buildUpdateHierarchicPropertiesQueryForMovedObject(
10192
$object,

library/orm/collection/IHierarchicCollection.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ public function getHierarchyOrderField();
8989
*/
9090
public function getHierarchyLevelField();
9191

92-
/**
93-
* Возвращает поле, которое используется у базового типа коллекции для хранения информации о количестве детей
94-
* @throws NonexistentEntityException если такого поля не существует
95-
* @return IField
96-
*/
97-
public function getHierarchyChildCountField();
98-
9992
/**
10093
* Возвращает поле, которое используется у базового типа коллекции для хранения последней части ЧПУ
10194
* @throws NonexistentEntityException если такого поля не существует

library/orm/collection/SimpleHierarchicCollection.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use umi\orm\exception\NonexistentEntityException;
1313
use umi\orm\metadata\IObjectType;
1414
use umi\orm\object\IHierarchicObject;
15-
use umi\orm\object\property\calculable\ICounterProperty;
1615

1716
/**
1817
* Простая коллекция иерархических объектов.
@@ -38,14 +37,10 @@ public function add($slug, $typeName = IObjectType::BASE, IHierarchicObject $bra
3837
->registerNewObject($this, $this->metadata->getType($typeName), $guid);
3938
$object->getProperty(IHierarchicObject::FIELD_SLUG)
4039
->setValue($slug);
40+
4141
if ($branch) {
4242
$object->getProperty(IHierarchicObject::FIELD_PARENT)
4343
->setValue($branch);
44-
/**
45-
* @var ICounterProperty $childCountProperty
46-
*/
47-
$childCountProperty = $branch->getProperty(IHierarchicObject::FIELD_CHILD_COUNT);
48-
$childCountProperty->increment();
4944
}
5045

5146
return $object;

library/orm/object/HierarchicObject.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@ public function getLevel()
6161
->getValue();
6262
}
6363

64-
/**
65-
* {@inheritdoc}
66-
*/
67-
public function getChildCount()
68-
{
69-
return $this->getProperty(self::FIELD_CHILD_COUNT)
70-
->getValue();
71-
}
72-
7364
/**
7465
* {@inheritdoc}
7566
*/

library/orm/object/IHierarchicObject.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ interface IHierarchicObject extends IObject
3131
* Имя поля, используемого для хранения информации о иерархическом порядке
3232
*/
3333
const FIELD_ORDER = 'order';
34-
/**
35-
* Имя поля, используемого для хранения количества непосредственных детей иерархических объектов
36-
*/
37-
const FIELD_CHILD_COUNT = 'childCount';
3834
/**
3935
* Имя поля, используемого для хранения последней части ЧПУ
4036
*/
@@ -68,12 +64,6 @@ public function getOrder();
6864
*/
6965
public function getLevel();
7066

71-
/**
72-
* Возвращает количество непостредственных детей
73-
* @return int
74-
*/
75-
public function getChildCount();
76-
7767
/**
7868
* Возвращает URI
7969
* @return string

library/orm/object/Object.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use umi\orm\collection\ICollection;
1818
use umi\orm\exception\InvalidArgumentException;
1919
use umi\orm\exception\NonexistentEntityException;
20-
use umi\orm\exception\NotAllowedOperationException;
2120
use umi\orm\exception\ReadOnlyEntityException;
2221
use umi\orm\exception\RuntimeException;
2322
use umi\orm\manager\IObjectManagerAware;

library/validation/ValidatorCollection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace umi\validation;
1111

12-
use Traversable;
13-
1412
/**
1513
* Класс коллекции валидаторов.
1614
* По очереди валидирует значение каждым валидатором.

tests/utest/form/unit/element/CheckboxElementTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
namespace utest\form\unit\element;
1111

1212
use umi\form\element\Checkbox;
13-
use umi\form\Form;
1413

1514
/**
1615
* Тесты элемента формы - Флаг

tests/utest/monolog/unit/MonologToolsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
use Monolog\Handler\FirePHPHandler;
1212
use Monolog\Handler\StreamHandler;
13-
use Monolog\Handler\SwiftMailerHandler;
1413
use Monolog\Logger;
1514
use umi\extension\monolog\exception\RuntimeException;
1615
use umi\extension\monolog\toolbox\MonologTools;

0 commit comments

Comments
 (0)