Skip to content

Commit c315690

Browse files
committed
Split combined getter/setter EntityInterface::isNew().
isNew() now only acts as getter and new method setNew() has been added as getter.
1 parent 6d433be commit c315690

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Association/BelongsToMany.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ protected function _saveLinks(EntityInterface $sourceEntity, array $targetEntiti
769769
// as new, we let save() sort out whether or not we have a new link
770770
// or if we are updating an existing link.
771771
if ($changedKeys) {
772-
$joint->isNew(true);
772+
$joint->setNew(true);
773773
$joint->unset($junction->getPrimaryKey())
774774
->set(array_merge($sourceKeys, $targetKeys), ['guard' => false]);
775775
}

Behavior/Translate/EavStrategy.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -462,11 +462,11 @@ protected function bundleTranslatedFields($entity)
462462
foreach ($find as $i => $translation) {
463463
if (!empty($results[$i])) {
464464
$contents[$i]->set('id', $results[$i], ['setter' => false]);
465-
$contents[$i]->isNew(false);
465+
$contents[$i]->setNew(false);
466466
} else {
467467
$translation['model'] = $this->_config['referenceName'];
468468
$contents[$i]->set($translation, ['setter' => false, 'guard' => false]);
469-
$contents[$i]->isNew(true);
469+
$contents[$i]->setNew(true);
470470
}
471471
}
472472

Entity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(array $properties = [], array $options = [])
6262
}
6363

6464
if ($options['markNew'] !== null) {
65-
$this->isNew($options['markNew']);
65+
$this->setNew($options['markNew']);
6666
}
6767

6868
if (!empty($properties) && $options['markClean'] && !$options['useSetters']) {

Table.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ public function save(EntityInterface $entity, $options = [])
17651765
}
17661766
if ($options['atomic'] || $options['_primary']) {
17671767
$entity->clean();
1768-
$entity->isNew(false);
1768+
$entity->setNew(false);
17691769
$entity->setSource($this->getRegistryAlias());
17701770
}
17711771
}
@@ -1813,7 +1813,7 @@ protected function _processSave(EntityInterface $entity, ArrayObject $options)
18131813
foreach ($entity->extract($primaryColumns) as $k => $v) {
18141814
$conditions["$alias.$k"] = $v;
18151815
}
1816-
$entity->isNew(!$this->exists($conditions));
1816+
$entity->setNew(!$this->exists($conditions));
18171817
}
18181818

18191819
$mode = $entity->isNew() ? RulesChecker::CREATE : RulesChecker::UPDATE;
@@ -1854,7 +1854,7 @@ protected function _processSave(EntityInterface $entity, ArrayObject $options)
18541854

18551855
if (!$success && $isNew) {
18561856
$entity->unset($this->getPrimaryKey());
1857-
$entity->isNew(true);
1857+
$entity->setNew(true);
18581858
}
18591859

18601860
return $success ? $entity : false;
@@ -1891,7 +1891,7 @@ protected function _onSaveSuccess(EntityInterface $entity, ArrayObject $options)
18911891

18921892
if (!$options['atomic'] && !$options['_primary']) {
18931893
$entity->clean();
1894-
$entity->isNew(false);
1894+
$entity->setNew(false);
18951895
$entity->setSource($this->getRegistryAlias());
18961896
}
18971897

@@ -2096,7 +2096,7 @@ protected function _saveMany(iterable $entities, $options = []): iterable
20962096
foreach ($entities as $key => $entity) {
20972097
if (isset($isNew[$key]) && $isNew[$key]) {
20982098
$entity->unset($this->getPrimaryKey());
2099-
$entity->isNew(true);
2099+
$entity->setNew(true);
21002100
}
21012101
}
21022102
};

0 commit comments

Comments
 (0)