setInContainerNotWritten
This commit is contained in:
@@ -207,6 +207,7 @@ class Entity extends BaseEntity
|
||||
*
|
||||
* @param ?array<string, string> $columns Deprecated as of v9.0.
|
||||
* @todo Add a method to load and set only fetched values?
|
||||
* @internal
|
||||
*/
|
||||
public function loadLinkMultipleField(string $field, ?array $columns = null): void
|
||||
{
|
||||
@@ -302,8 +303,8 @@ class Entity extends BaseEntity
|
||||
|
||||
$toSetFetched = !$this->isNew() && !$this->hasFetched($idsAttribute);
|
||||
|
||||
$this->set($idsAttribute, $ids);
|
||||
$this->set($namesAttribute, $names);
|
||||
$this->setInContainerNotWritten($idsAttribute, $ids);
|
||||
$this->setInContainerNotWritten($namesAttribute, $names);
|
||||
|
||||
if ($toSetFetched) {
|
||||
$this->setFetched($idsAttribute, $ids);
|
||||
@@ -319,7 +320,7 @@ class Entity extends BaseEntity
|
||||
}
|
||||
|
||||
if ($columns) {
|
||||
$this->set($columnsAttribute, $columnsData);
|
||||
$this->setInContainerNotWritten($columnsAttribute, $columnsData);
|
||||
|
||||
if ($toSetFetched) {
|
||||
$this->setFetched($columnsAttribute, $columnsData);
|
||||
@@ -350,7 +351,6 @@ class Entity extends BaseEntity
|
||||
$select = [Attribute::ID, Field::NAME];
|
||||
|
||||
$entity = $this->entityManager
|
||||
->getRDBRepository($this->getEntityType())
|
||||
->getRelation($this, $field)
|
||||
->select($select)
|
||||
->findOne();
|
||||
@@ -375,8 +375,8 @@ class Entity extends BaseEntity
|
||||
return;
|
||||
}
|
||||
|
||||
$this->set($idAttribute, $entityId);
|
||||
$this->set($nameAttribute, $entityName);
|
||||
$this->setInContainerNotWritten($idAttribute, $entityId);
|
||||
$this->setInContainerNotWritten($nameAttribute, $entityName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -274,16 +274,28 @@ class BaseEntity implements Entity
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value in the container.
|
||||
*
|
||||
* @param mixed $value
|
||||
* Set a value in the container. To be used wisely. Use `set` instead.
|
||||
*/
|
||||
protected function setInContainer(string $attribute, $value): void
|
||||
protected function setInContainer(string $attribute, mixed $value): void
|
||||
{
|
||||
$this->valuesContainer[$attribute] = $value;
|
||||
|
||||
$this->writtenMap[$attribute] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Not to be used. To be used internally for lazy-loading purpose.
|
||||
*
|
||||
* @internal
|
||||
* @since 9.1.0
|
||||
*/
|
||||
protected function setInContainerNotWritten(string $attribute, mixed $value): void
|
||||
{
|
||||
$this->valuesContainer[$attribute] = $value;
|
||||
|
||||
unset($this->writtenMap[$attribute]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an attribute is set in the container.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user