Skip to content

Commit

Permalink
[orm] rename formula to delayed field
Browse files Browse the repository at this point in the history
  • Loading branch information
Daria Prusova committed Jul 31, 2014
1 parent 89b19f1 commit 2ee405f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions orm/collection/BaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
use umi\orm\manager\TObjectManagerAware;
use umi\orm\metadata\field\IField;
use umi\orm\metadata\field\relation\ManyToManyRelationField;
use umi\orm\metadata\field\special\FormulaField;
use umi\orm\metadata\field\special\DelayedField;
use umi\orm\metadata\IMetadata;
use umi\orm\metadata\IObjectType;
use umi\orm\object\IObject;
Expand Down Expand Up @@ -415,15 +415,15 @@ public function persistNewObject(IObject $object)
/**
* {@inheritdoc}
*/
public function persistRecalculatedObject(IObject $object, array $formulaProperties)
public function persistRecalculatedObject(IObject $object, array $delayedProperties)
{
if (!$this->contains($object)) {
throw new NotAllowedOperationException($this->translate(
'Cannot persist modified object. Object from another collection given.'
));
}
if (count($formulaProperties)) {
$this->executeUpdate($object, $formulaProperties);
if (count($delayedProperties)) {
$this->executeUpdate($object, $delayedProperties);
}
}

Expand All @@ -439,18 +439,18 @@ public function persistModifiedObject(IObject $object)
}

$modifiedProperties = [];
$formulaProperties = [];
$delayedProperties = [];

foreach ($object->getModifiedProperties()as $property) {
if ($property->getField() instanceof FormulaField) {
$formulaProperties[] = $property;
if ($property->getField() instanceof DelayedField) {
$delayedProperties[] = $property;
} else {
$modifiedProperties[] = $property;
}
}

if ($formulaProperties) {
$this->getObjectPersister()->storeRecalculatedObject($object, $formulaProperties);
if ($delayedProperties) {
$this->getObjectPersister()->storeRecalculatedObject($object, $delayedProperties);
}

if (count($modifiedProperties)) {
Expand Down
4 changes: 2 additions & 2 deletions orm/collection/ICollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@ public function persistModifiedObject(IObject $object);
* которые должны быть вычислены после сохранения всех объектов.
* @internal
* @param IObject $object
* @param IProperty[] $formulaProperties
* @param IProperty[] $delayedProperties
* @return
*/
public function persistRecalculatedObject(IObject $object, array $formulaProperties);
public function persistRecalculatedObject(IObject $object, array $delayedProperties);

/**
* Запускает запросы на удаление объекта коллекции.
Expand Down
6 changes: 3 additions & 3 deletions orm/collection/LinkedHierarchicCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,16 @@ public function persistModifiedObject(IObject $object)
/**
* {@inheritdoc}
*/
public function persistRecalculatedObject(IObject $object, array $formulaProperties)
public function persistRecalculatedObject(IObject $object, array $delayedProperties)
{
if (!$this->contains($object)) {
throw new NotAllowedOperationException($this->translate(
'Cannot persist recalculated object. Object from another collection given.'
));
}
$this->getCommonHierarchy()
->persistRecalculatedObject($object, $formulaProperties);
parent::persistRecalculatedObject($object, $formulaProperties);
->persistRecalculatedObject($object, $delayedProperties);
parent::persistRecalculatedObject($object, $delayedProperties);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion orm/metadata/field/IField.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ interface IField
const TYPE_ORDER = 'order';

const TYPE_COUNTER = 'counter';
const TYPE_FORMULA = 'formula';
const TYPE_DELAYED = 'delayed';

const TYPE_PASSWORD = 'password';
const TYPE_MONEY = 'money';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
use umi\orm\object\IObject;

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

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

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

Expand Down
2 changes: 1 addition & 1 deletion orm/toolbox/factory/MetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class MetadataFactory implements IMetadataFactory, IFactory
IField::TYPE_LEVEL => 'umi\orm\metadata\field\special\LevelField',
IField::TYPE_ORDER => 'umi\orm\metadata\field\special\OrderField',
IField::TYPE_COUNTER => 'umi\orm\metadata\field\special\CounterField',
IField::TYPE_FORMULA => 'umi\orm\metadata\field\special\FormulaField',
IField::TYPE_DELAYED => 'umi\orm\metadata\field\special\DelayedField',
IField::TYPE_MONEY => 'umi\orm\metadata\field\special\MoneyField',
IField::TYPE_PASSWORD => 'umi\orm\metadata\field\special\PasswordField',
IField::TYPE_FILE => 'umi\orm\metadata\field\special\FileField',
Expand Down

0 comments on commit 2ee405f

Please sign in to comment.