Skip to content

Commit cc1d5f2

Browse files
author
Daria Prusova
committed
[orm] rename formula to delayed field
1 parent ab2a518 commit cc1d5f2

File tree

9 files changed

+33
-33
lines changed

9 files changed

+33
-33
lines changed

library/orm/collection/BaseCollection.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use umi\orm\manager\TObjectManagerAware;
2424
use umi\orm\metadata\field\IField;
2525
use umi\orm\metadata\field\relation\ManyToManyRelationField;
26-
use umi\orm\metadata\field\special\FormulaField;
26+
use umi\orm\metadata\field\special\DelayedField;
2727
use umi\orm\metadata\IMetadata;
2828
use umi\orm\metadata\IObjectType;
2929
use umi\orm\object\IObject;
@@ -415,15 +415,15 @@ public function persistNewObject(IObject $object)
415415
/**
416416
* {@inheritdoc}
417417
*/
418-
public function persistRecalculatedObject(IObject $object, array $formulaProperties)
418+
public function persistRecalculatedObject(IObject $object, array $delayedProperties)
419419
{
420420
if (!$this->contains($object)) {
421421
throw new NotAllowedOperationException($this->translate(
422422
'Cannot persist modified object. Object from another collection given.'
423423
));
424424
}
425-
if (count($formulaProperties)) {
426-
$this->executeUpdate($object, $formulaProperties);
425+
if (count($delayedProperties)) {
426+
$this->executeUpdate($object, $delayedProperties);
427427
}
428428
}
429429

@@ -439,18 +439,18 @@ public function persistModifiedObject(IObject $object)
439439
}
440440

441441
$modifiedProperties = [];
442-
$formulaProperties = [];
442+
$delayedProperties = [];
443443

444444
foreach ($object->getModifiedProperties()as $property) {
445-
if ($property->getField() instanceof FormulaField) {
446-
$formulaProperties[] = $property;
445+
if ($property->getField() instanceof DelayedField) {
446+
$delayedProperties[] = $property;
447447
} else {
448448
$modifiedProperties[] = $property;
449449
}
450450
}
451451

452-
if ($formulaProperties) {
453-
$this->getObjectPersister()->storeRecalculatedObject($object, $formulaProperties);
452+
if ($delayedProperties) {
453+
$this->getObjectPersister()->storeRecalculatedObject($object, $delayedProperties);
454454
}
455455

456456
if (count($modifiedProperties)) {

library/orm/collection/ICollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ public function persistModifiedObject(IObject $object);
193193
* которые должны быть вычислены после сохранения всех объектов.
194194
* @internal
195195
* @param IObject $object
196-
* @param IProperty[] $formulaProperties
196+
* @param IProperty[] $delayedProperties
197197
* @return
198198
*/
199-
public function persistRecalculatedObject(IObject $object, array $formulaProperties);
199+
public function persistRecalculatedObject(IObject $object, array $delayedProperties);
200200

201201
/**
202202
* Запускает запросы на удаление объекта коллекции.

library/orm/collection/LinkedHierarchicCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ public function persistModifiedObject(IObject $object)
8686
/**
8787
* {@inheritdoc}
8888
*/
89-
public function persistRecalculatedObject(IObject $object, array $formulaProperties)
89+
public function persistRecalculatedObject(IObject $object, array $delayedProperties)
9090
{
9191
if (!$this->contains($object)) {
9292
throw new NotAllowedOperationException($this->translate(
9393
'Cannot persist recalculated object. Object from another collection given.'
9494
));
9595
}
9696
$this->getCommonHierarchy()
97-
->persistRecalculatedObject($object, $formulaProperties);
98-
parent::persistRecalculatedObject($object, $formulaProperties);
97+
->persistRecalculatedObject($object, $delayedProperties);
98+
parent::persistRecalculatedObject($object, $delayedProperties);
9999
}
100100

101101
/**

library/orm/metadata/field/IField.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ interface IField
5757
const TYPE_ORDER = 'order';
5858

5959
const TYPE_COUNTER = 'counter';
60-
const TYPE_FORMULA = 'formula';
60+
const TYPE_DELAYED = 'delayed';
6161

6262
const TYPE_PASSWORD = 'password';
6363
const TYPE_MONEY = 'money';

library/orm/metadata/field/special/FormulaField.php renamed to library/orm/metadata/field/special/DelayedField.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
use umi\orm\object\IObject;
2222

2323
/**
24-
* Класс поля, значение которого вычисляется по формуле
24+
* Класс поля, значение которого вычисляется заданным методом после сохранения всех объектов.
2525
*/
26-
class FormulaField extends BaseField implements IScalarField, ICalculableField
26+
class DelayedField extends BaseField implements IScalarField, ICalculableField
2727
{
2828
use TScalarField;
2929
use TCalculableField;
@@ -99,20 +99,20 @@ protected function applyConfiguration(array $config)
9999
{
100100
if (!isset($config['dataType']) || !is_string($config['dataType'])) {
101101
throw new UnexpectedValueException($this->translate(
102-
'Formula field configuration should contain data type and it should be a string.'
102+
'Delayed field configuration should contain data type and it should be a string.'
103103
));
104104
}
105105

106106
if (!in_array($config['dataType'], $this->allowedDataTypes)) {
107107
throw new OutOfBoundsException($this->translate(
108-
'Data type "{type}" is not supported for formula field.',
108+
'Data type "{type}" is not supported for delayed field.',
109109
['type' => $config['dataType']]
110110
));
111111
}
112112

113113
if (!isset($config['formula']) || !is_string($config['formula'])) {
114114
throw new UnexpectedValueException($this->translate(
115-
'Formula field configuration should contain formula and it should be a string.'
115+
'Delayed field configuration should contain option "formula" and it should be a string.'
116116
));
117117
}
118118

library/orm/toolbox/factory/MetadataFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class MetadataFactory implements IMetadataFactory, IFactory
7777
IField::TYPE_LEVEL => 'umi\orm\metadata\field\special\LevelField',
7878
IField::TYPE_ORDER => 'umi\orm\metadata\field\special\OrderField',
7979
IField::TYPE_COUNTER => 'umi\orm\metadata\field\special\CounterField',
80-
IField::TYPE_FORMULA => 'umi\orm\metadata\field\special\FormulaField',
80+
IField::TYPE_DELAYED => 'umi\orm\metadata\field\special\DelayedField',
8181
IField::TYPE_MONEY => 'umi\orm\metadata\field\special\MoneyField',
8282
IField::TYPE_PASSWORD => 'umi\orm\metadata\field\special\PasswordField',
8383
IField::TYPE_FILE => 'umi\orm\metadata\field\special\FileField',

tests/utest/orm/func/object/property/ObjectFormulaPropertiesTest.php renamed to tests/utest/orm/func/object/property/ObjectDelayedPropertiesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Тесты для вычисляемых при сохранении свойств объекта
1818
*/
19-
class ObjectFormulaPropertiesTest extends ORMDbTestCase
19+
class ObjectDelayedPropertiesTest extends ORMDbTestCase
2020
{
2121

2222
/**

tests/utest/orm/mock/collections/metadata/users_user.config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
'firstName' => ['type' => IField::TYPE_STRING, 'columnName' => 'first_name'],
2424
'lastName' => ['type' => IField::TYPE_STRING, 'columnName' => 'last_name'],
25-
'fullName' => ['type' => IField::TYPE_FORMULA, 'columnName' => 'full_name', 'formula' => 'calculateFullName', 'dataType' => 'string'],
25+
'fullName' => ['type' => IField::TYPE_DELAYED, 'columnName' => 'full_name', 'formula' => 'calculateFullName', 'dataType' => 'string'],
2626

2727
'group' => ['type' => IField::TYPE_BELONGS_TO, 'columnName' => 'group_id', 'target' => 'users_group'],
2828
'profile' => ['type' => IField::TYPE_HAS_ONE, 'target' => 'users_profile', 'targetField' => 'user'],

tests/utest/orm/unit/metadata/field/special/FormulaFieldTest.php renamed to tests/utest/orm/unit/metadata/field/special/DelayedFieldTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,23 @@
1010
namespace utest\orm\unit\metadata\field\special;
1111

1212
use umi\orm\metadata\field\IField;
13-
use umi\orm\metadata\field\special\FormulaField;
13+
use umi\orm\metadata\field\special\DelayedField;
1414
use utest\orm\unit\metadata\field\FieldTestCase;
1515

1616
/**
1717
* Тест поля хранителя связи.
1818
*/
19-
class FormulaFieldTest extends FieldTestCase
19+
class DelayedFieldTest extends FieldTestCase
2020
{
2121

2222
/**
2323
* {@inheritdoc}
2424
*/
2525
protected function getField()
2626
{
27-
return new FormulaField(
27+
return new DelayedField(
2828
'mock',
29-
IField::TYPE_FORMULA,
29+
IField::TYPE_DELAYED,
3030
[
3131
'dataType' => 'string',
3232
'formula' => 'recalculateValue'
@@ -39,37 +39,37 @@ public function testConfig()
3939
$config = [];
4040
$e = null;
4141
try {
42-
new FormulaField('mock', IField::TYPE_FORMULA, $config);
42+
new DelayedField('mock', IField::TYPE_DELAYED, $config);
4343
} catch (\Exception $e) {
4444
}
4545
$this->assertInstanceOf(
4646
'umi\orm\exception\UnexpectedValueException',
4747
$e,
48-
'Ожидается исключение при попытке создать поле FormulaField без указания типа данных'
48+
'Ожидается исключение при попытке создать поле DelayedField без указания типа данных'
4949
);
5050

5151
$config['dataType'] = 'wrongDataType';
5252
$e = null;
5353
try {
54-
new FormulaField('mock', IField::TYPE_FORMULA, $config);
54+
new DelayedField('mock', IField::TYPE_DELAYED, $config);
5555
} catch (\Exception $e) {
5656
}
5757
$this->assertInstanceOf(
5858
'umi\orm\exception\OutOfBoundsException',
5959
$e,
60-
'Ожидается исключение при попытке создать поле FormulaField с неверным типом данных'
60+
'Ожидается исключение при попытке создать поле DelayedField с неверным типом данных'
6161
);
6262

6363
$config['dataType'] = 'string';
6464
$e = null;
6565
try {
66-
new FormulaField('mock', IField::TYPE_FORMULA, $config);
66+
new DelayedField('mock', IField::TYPE_DELAYED, $config);
6767
} catch (\Exception $e) {
6868
}
6969
$this->assertInstanceOf(
7070
'umi\orm\exception\UnexpectedValueException',
7171
$e,
72-
'Ожидается исключение при попытке создать поле FormulaField без указания на метод, вычисляющий значение'
72+
'Ожидается исключение при попытке создать поле DelayedField без указания на метод, вычисляющий значение'
7373
);
7474

7575
}

0 commit comments

Comments
 (0)