Class EntityStorage store only one type of entity per instance
Definition at line 14 of file EntityStorage.php.
◆ add()
Add entity to registry if entity in it
- Parameters
-
\Magento\Framework\Model\AbstractModel | $entity | |
- Returns
- void
Definition at line 60 of file EntityStorage.php.
◆ addByIdentifyingFields()
addByIdentifyingFields |
( |
FrameworkAbstractModel |
$object, |
|
|
array |
$identifyingFields, |
|
|
|
$storageName |
|
) |
| |
Adds entity using identifying fields mapping, entity should have an id
- Parameters
-
FrameworkAbstractModel | $object | |
array | $identifyingFields | |
string | $storageName | |
- Returns
- void
- Exceptions
-
Definition at line 42 of file EntityStorage.php.
44 if (empty($identifyingFields)) {
45 throw new \Magento\Framework\Exception\InputException(
__(
'Identifying Fields required'));
47 if (!$object->getId()) {
48 throw new \Magento\Framework\Exception\InputException(
__(
'An ID is needed. Set the ID and try again.'));
50 $this->storageMapper[$storageName][$this->
getHash($identifyingFields)] = $object->getId();
51 $this->registry[$object->getId()] = $object;
◆ get()
Retrieve entity from registry if entity in it
- Parameters
-
- Returns
- bool|FrameworkAbstractModel
Definition at line 71 of file EntityStorage.php.
74 return $this->registry[
$id];
◆ getByIdentifyingFields()
getByIdentifyingFields |
( |
array |
$identifyingFields, |
|
|
|
$storageName |
|
) |
| |
Gets entity by identifying fields
- Parameters
-
array | $identifyingFields | |
string | $storageName | |
- Returns
- bool|FrameworkAbstractModel
Definition at line 86 of file EntityStorage.php.
88 $hash = $this->
getHash($identifyingFields);
89 if (isset($this->storageMapper[$storageName][$hash])) {
90 return $this->
get($this->storageMapper[$storageName][$hash]);
◆ getHash()
Gets hash using concatenation of identifying fields
- Parameters
-
- Returns
- string
Definition at line 125 of file EntityStorage.php.
127 $stringForKey = implode(self::GLUE,
$fields);
128 return sha1($stringForKey);
◆ has()
Checks if entity is in storage
- Parameters
-
- Returns
- bool
Definition at line 114 of file EntityStorage.php.
116 return isset($this->registry[
$id]);
◆ remove()
Remove entity from storage
- Parameters
-
- Returns
- void
Definition at line 101 of file EntityStorage.php.
104 unset($this->registry[
$id]);
◆ $registry
◆ $storageMapper
◆ GLUE
The documentation for this class was generated from the following file: