LazyObjectStorage extends ObjectStorage implements LoadingStrategyInterface

A proxy that can replace any object and replaces itself in it's parent on first access (call, get, set, isset, unset).

Internal

only to be used within Extbase, not part of TYPO3 Core API.

Tags
template

TEntity

extends

ObjectStorage<TEntity>

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 (eg. by adding a new object)
$parentObject  : DomainObjectInterface
The object this property is contained in.
$positionCounter  : int
An internal var 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 objectstorage
$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
Constructs this proxy instance.
__serialize()  : array<string|int, mixed>
__unserialize()  : void
_isDirty()  : bool
Returns TRUE if the storage was modified after reconstitution.
_memorizeCleanState()  : mixed
Register the storage's clean state, e.g. after it has been reconstituted from the database.
addAll()  : void
Adds all objects-data pairs from a different storage in the current storage.
attach()  : void
Adds an object in the storage, and optionally associate it to some data.
contains()  : bool
Checks if the storage contains a specific object.
count()  : 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 data, or info, associated with the object pointed by the current iterator position.
getPosition()  : int|null
isInitialized()  : bool
Returns the state of the initialization
isRelationDirty()  : bool
Returns TRUE if an object is 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 data associated with an object, or the object itself if an integer is passed.
offsetSet()  : void
Associates data 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.
serialize()  : mixed
Dummy method to avoid serialization.
setInfo()  : mixed
Associates data, or info, with the object currently pointed to by the iterator.
toArray()  : array<string|int, mixed>
Returns this object storage as an array
unserialize()  : mixed
Dummy method to avoid unserialization.
valid()  : bool
Checks if the array pointer of the storage points to a valid position.
initialize()  : mixed
This is a function lazy load implementation.
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 objectstorage

$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 (eg. by adding a new object)

protected bool $isModified = false

$positionCounter

An internal var holding the count of added objects to be stored as position.

protected int $positionCounter = 0

It would be reset, when all objects will be removed from the objectstorage

$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 objectstorage

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 = []

array( spl_object_hash => array( 'obj' => $object, 'inf' => $information ) )

Methods

__construct()

Constructs this proxy instance.

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 it's 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() : bool
Return values
bool

_memorizeCleanState()

Register the storage's clean state, e.g. after it has been reconstituted from the database.

public _memorizeCleanState() : mixed

addAll()

Adds all objects-data pairs from a different storage in the current storage.

public addAll(ObjectStorage $storage) : void
Parameters
$storage : ObjectStorage
Tags
see
ObjectStorage::addAll

attach()

Adds an object in the storage, and optionally associate it to some data.

public attach(TEntity $object[, mixed $data = null ]) : void
Parameters
$object : TEntity

The object to add.

$data : mixed = null

The data to associate with the object.

Tags
see
ObjectStorage::attach

contains()

Checks if the storage contains a specific object.

public contains(TEntity $object) : bool
Parameters
$object : TEntity

The object to look for.

Tags
see
ObjectStorage::contains
Return values
bool

count()

Counts the elements in the storage array

public count() : int
Tags
throws
Exception
Return values
int

The number of elements in the ObjectStorage

current()

Returns the current storage entry.

public current() : TEntity|null
Tags
see
ObjectStorage::current
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
see
ObjectStorage::detach

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 data, or info, associated with the object pointed by the current iterator position.

public getInfo() : mixed
Return values
mixed

The data associated with the current iterator position.

getPosition()

public getPosition(mixed $object) : int|null
Parameters
$object : mixed
Return values
int|null

isInitialized()

Returns the state of the initialization

public isInitialized() : bool
Return values
bool

isRelationDirty()

Returns TRUE if an object is added, then removed and added at a different position

public isRelationDirty(mixed $object) : bool
Parameters
$object : mixed
Return values
bool

key()

Returns the index at which the iterator currently is.

public key() : string
Tags
see
ObjectStorage::key
Return values
string

The index corresponding to the position of the iterator.

next()

Moves to the next entry.

public next() : void
Tags
see
ObjectStorage::next

offsetExists()

Checks whether an object exists in the storage.

public offsetExists(TEntity $value) : bool
Parameters
$value : TEntity

The object to look for, or the key in the storage.

Tags
see
ObjectStorage::offsetExists
Return values
bool

offsetGet()

Returns the data associated with an object, or the object itself if an integer is passed.

public offsetGet(TEntity $value) : mixed
Parameters
$value : TEntity

The object to look for, or its key in the storage.

Tags
see
ObjectStorage::offsetGet
Attributes
#[ReturnTypeWillChange]

offsetSet()

Associates data to an object in the storage. offsetSet() is an alias of attach().

public offsetSet(TEntity $object, mixed $info) : void
Parameters
$object : TEntity

The object to add.

$info : mixed

The data to associate with the object.

Tags
see
ObjectStorage::offsetSet

offsetUnset()

Removes an object from the storage. offsetUnset() is an alias of detach().

public offsetUnset(TEntity $value) : void
Parameters
$value : TEntity

The object to remove, or its key in the storage.

Tags
see
ObjectStorage::offsetUnset

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
see
ObjectStorage::removeAll

rewind()

Rewinds the iterator to the first storage element.

public rewind() : void
Tags
see
ObjectStorage::rewind

serialize()

Dummy method to avoid serialization.

public serialize() : mixed
Tags
throws
RuntimeException
todo:

serialize() is not called when \Serializable interface is not implemented. Obsolete method. Drop in v12.

setInfo()

Associates data, or info, with the object currently pointed to by the iterator.

public setInfo(mixed $data) : mixed
Parameters
$data : mixed

toArray()

Returns this object storage as an array

public toArray() : array<string|int, mixed>
Tags
see
ObjectStorage::toArray
Return values
array<string|int, mixed>

unserialize()

Dummy method to avoid unserialization.

public unserialize() : mixed
Tags
throws
RuntimeException
todo:

unserialize() is not called when \Serializable interface is not implemented. Obsolete method. Drop in v12.

valid()

Checks if the array pointer of the storage points to a valid position.

public valid() : bool
Tags
see
ObjectStorage::valid
Return values
bool

initialize()

This is a function lazy load implementation.

protected initialize() : mixed

isStorageAlreadyMemorizedInParentCleanState()

protected isStorageAlreadyMemorizedInParentCleanState() : bool
Return values
bool

        
On this page

Search results