LazyObjectStorage extends ObjectStorage implements LoadingStrategyInterface
A proxy that can replace any object and replaces itself in its parent on the first access (`call`, `get`, `set`, `isset`, `unset`).
only to be used within Extbase, not part of TYPO3 Core API.
Tags
Table of Contents
Interfaces
- LoadingStrategyInterface
- An interface for the lazy loading strategies.
Properties
- $addedObjectsPositions : array<string|int, mixed>
- An array holding the internal position the object was added.
- $dataMapper : DataMapper
- $fieldValue : mixed
- The raw field value.
- $isInitialized : bool
- $isModified : bool
- A flag indication if the object storage was modified after reconstitution (e.g., by adding a new object)
- $parentObject : DomainObjectInterface
- The object this property is contained in.
- $positionCounter : int
- An internal variable holding the count of added objects to be stored as position.
- $propertyName : string
- The name of the property represented by this proxy.
- $removedObjectsPositions : array<string|int, mixed>
- An array holding the internal position the object was added before, when it would be removed from the object storage.
- $storage : array<string|int, mixed>
- An array holding the objects and the stored information. The key of the array items ist the spl_object_hash of the given object.
Methods
- __construct() : mixed
- __serialize() : array<string|int, mixed>
- __unserialize() : void
- _isDirty() : bool
- Returns `true` if the storage was modified after reconstitution.
- _memorizeCleanState() : void
- Register the storage's clean state, e.g., after it has been reconstituted from the database.
- addAll() : void
- Adds all object-information pairs from a different storage in the current storage.
- attach() : void
- Adds an object in the storage, and optionally associate it to some information.
- contains() : bool
- Checks if the storage contains a specific object.
- count() : 0|positive-int
- Counts the elements in the storage array
- current() : TEntity|null
- Returns the current storage entry.
- detach() : void
- Removes an object from the storage.
- getArray() : array<int, TEntity>
- Alias of `toArray` which allows that method to be used from contexts which support for example dotted paths, e.g., `ObjectAccess::getPropertyPath($object, 'children.array.123')` to get exactly the 123rd item in the `children` property which is an `ObjectStorage`.
- getInfo() : mixed
- Returns the information associated with the object pointed by the current iterator position.
- getPosition() : int|null
- isInitialized() : bool
- isRelationDirty() : bool
- Returns `true` if an object was added, then removed and added at a different position.
- key() : string
- Returns the index at which the iterator currently is.
- next() : void
- Moves to the next entry.
- offsetExists() : bool
- Checks whether an object exists in the storage.
- offsetGet() : mixed
- Returns the information associated with an object, or the object itself if an integer is passed.
- offsetSet() : void
- Associates information to an object in the storage. `offsetSet()` is an alias of `attach()`.
- offsetUnset() : void
- Removes an object from the storage. `offsetUnset()` is an alias of `detach()`.
- removeAll() : void
- Removes objects contained in another storage from the current storage.
- rewind() : void
- Rewinds the iterator to the first storage element.
- setInfo() : mixed
- Associates information with the object currently pointed to by the iterator.
- toArray() : array<int, TEntity>
- Returns this object storage as an array.
- valid() : bool
- Checks if the array pointer of the storage points to a valid position.
- initialize() : mixed
- Lazily initializes the object storage.
- isStorageAlreadyMemorizedInParentCleanState() : bool
Properties
$addedObjectsPositions
An array holding the internal position the object was added.
protected
array<string|int, mixed>
$addedObjectsPositions
= []
The object entry is unset when the object gets removed from the object storage.
$dataMapper
protected
DataMapper
$dataMapper
$fieldValue
The raw field value.
protected
mixed
$fieldValue
$isInitialized
protected
bool
$isInitialized
= false
$isModified
A flag indication if the object storage was modified after reconstitution (e.g., by adding a new object)
protected
bool
$isModified
= false
$parentObject
The object this property is contained in.
protected
DomainObjectInterface
$parentObject
$positionCounter
An internal variable holding the count of added objects to be stored as position.
protected
int
$positionCounter
= 0
It will be reset when all objects are be removed from the object storage.
$propertyName
The name of the property represented by this proxy.
protected
string
$propertyName
$removedObjectsPositions
An array holding the internal position the object was added before, when it would be removed from the object storage.
protected
array<string|int, mixed>
$removedObjectsPositions
= []
$storage
An array holding the objects and the stored information. The key of the array items ist the spl_object_hash of the given object.
protected
array<string|int, mixed>
$storage
= []
[
'spl_object_hash' => [
'obj' => $object,
'inf' => $information,
],
]
Methods
__construct()
public
__construct(TEntity $parentObject, string $propertyName, mixed $fieldValue[, DataMapper|null $dataMapper = null ]) : mixed
Parameters
- $parentObject : TEntity
-
The object instance this proxy is part of
- $propertyName : string
-
The name of the proxied property in its parent
- $fieldValue : mixed
-
The raw field value.
- $dataMapper : DataMapper|null = null
__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
_isDirty()
Returns `true` if the storage was modified after reconstitution.
public
_isDirty([non-empty-string|null $propertyName = null ]) : bool
Parameters
- $propertyName : non-empty-string|null = null
Return values
bool_memorizeCleanState()
Register the storage's clean state, e.g., after it has been reconstituted from the database.
public
_memorizeCleanState([non-empty-string|null $propertyName = null ]) : void
Parameters
- $propertyName : non-empty-string|null = null
addAll()
Adds all object-information pairs from a different storage in the current storage.
public
addAll(ObjectStorage $storage) : void
Parameters
- $storage : ObjectStorage
Tags
attach()
Adds an object in the storage, and optionally associate it to some information.
public
attach(TEntity $object[, mixed $information = null ]) : void
Parameters
- $object : TEntity
-
The object to add.
- $information : mixed = null
-
The information to associate with the object.
Tags
contains()
Checks if the storage contains a specific object.
public
contains(TEntity $object) : bool
Parameters
- $object : TEntity
-
The object to look for.
Tags
Return values
boolcount()
Counts the elements in the storage array
public
count() : 0|positive-int
Tags
Return values
0|positive-int —The number of objects in the storage.
current()
Returns the current storage entry.
public
current() : TEntity|null
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
TEntity|null —The object at the current iterator position.
detach()
Removes an object from the storage.
public
detach(TEntity $object) : void
Parameters
- $object : TEntity
-
The object to remove.
Tags
getArray()
Alias of `toArray` which allows that method to be used from contexts which support for example dotted paths, e.g., `ObjectAccess::getPropertyPath($object, 'children.array.123')` to get exactly the 123rd item in the `children` property which is an `ObjectStorage`.
public
getArray() : array<int, TEntity>
Return values
array<int, TEntity>getInfo()
Returns the information associated with the object pointed by the current iterator position.
public
getInfo() : mixed
Return values
mixed —The information associated with the current iterator position.
getPosition()
public
getPosition(mixed $object) : int|null
Parameters
- $object : mixed
Return values
int|nullisInitialized()
public
isInitialized() : bool
Return values
boolisRelationDirty()
Returns `true` if an object was added, then removed and added at a different position.
public
isRelationDirty(mixed $object) : bool
Parameters
- $object : mixed
Return values
boolkey()
Returns the index at which the iterator currently is.
public
key() : string
Tags
Return values
string —The index corresponding to the position of the iterator.
next()
Moves to the next entry.
public
next() : void
Tags
offsetExists()
Checks whether an object exists in the storage.
public
offsetExists(TEntity|int|string $value) : bool
Parameters
- $value : TEntity|int|string
-
The object to look for, or the key in the storage.
Tags
Return values
booloffsetGet()
Returns the information associated with an object, or the object itself if an integer is passed.
public
offsetGet(TEntity|int|string $value) : mixed
Parameters
- $value : TEntity|int|string
-
The object to look for, or its key in the storage.
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —The information associated with an object in the storage, or the object itself if an integer is passed.
offsetSet()
Associates information to an object in the storage. `offsetSet()` is an alias of `attach()`.
public
offsetSet(TEntity|string|null $object, mixed $information) : void
Parameters
- $object : TEntity|string|null
-
The object to add.
- $information : mixed
-
The information to associate with the object.
Tags
offsetUnset()
Removes an object from the storage. `offsetUnset()` is an alias of `detach()`.
public
offsetUnset(TEntity|string|null $value) : void
Parameters
- $value : TEntity|string|null
-
The object to remove, or its key in the storage.
Tags
removeAll()
Removes objects contained in another storage from the current storage.
public
removeAll(ObjectStorage $storage) : void
Parameters
- $storage : ObjectStorage
-
The storage containing the elements to remove.
Tags
rewind()
Rewinds the iterator to the first storage element.
public
rewind() : void
Tags
setInfo()
Associates information with the object currently pointed to by the iterator.
public
setInfo(mixed $information) : mixed
Parameters
- $information : mixed
toArray()
Returns this object storage as an array.
public
toArray() : array<int, TEntity>
Tags
Return values
array<int, TEntity>valid()
Checks if the array pointer of the storage points to a valid position.
public
valid() : bool
Tags
Return values
boolinitialize()
Lazily initializes the object storage.
protected
initialize() : mixed
isStorageAlreadyMemorizedInParentCleanState()
protected
isStorageAlreadyMemorizedInParentCleanState() : bool