TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
ObjectStorage Class Reference
Inheritance diagram for ObjectStorage:
ObjectMonitoringInterface LazyObjectStorage

Public Member Functions

 rewind ()
 
 valid ()
 
 key ()
 
 current ()
 
 next ()
 
 count ()
 
 offsetSet ($object, $information)
 
 offsetExists ($object)
 
 offsetUnset ($object)
 
 offsetGet ($object)
 
 contains ($object)
 
 attach ($object, $information=null)
 
 detach ($object)
 
 getInfo ()
 
 setInfo ($data)
 
 addAll (ObjectStorage $objectStorage)
 
 removeAll (ObjectStorage $objectStorage)
 
 toArray ()
 
 getArray ()
 
 serialize ()
 
 unserialize ($serialized)
 
 _memorizeCleanState ()
 
 _isDirty ()
 
 isRelationDirty ($object)
 
 getPosition ($object)
 

Protected Attributes

 $storage = []
 
 $isModified = false
 
 $addedObjectsPositions = []
 
 $removedObjectsPositions = []
 
 $positionCounter = 0
 

Private Attributes

 $warning = 'You should never see this warning. If you do, you probably used PHP array functions like current() on the TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage. To retrieve the first result, you can use the rewind() and current() methods.'
 

Detailed Description

The storage for objects. It ensures the uniqueness of an object in the storage. It's a remake of the SplObjectStorage introduced in PHP 5.3.

Opposed to the SplObjectStorage the ObjectStorage does not implement the Serializable interface.

Definition at line 23 of file ObjectStorage.php.

Member Function Documentation

_isDirty ( )

Returns TRUE if the storage was modified after reconstitution.

Returns
bool

Implements ObjectMonitoringInterface.

Definition at line 351 of file ObjectStorage.php.

References ObjectStorage\$isModified.

_memorizeCleanState ( )

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

Returns
void

Implements ObjectMonitoringInterface.

Definition at line 341 of file ObjectStorage.php.

Referenced by LazyObjectStorage\initialize().

addAll ( ObjectStorage  $objectStorage)

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

Parameters
ObjectStorage$objectStorage
Returns
void

Definition at line 266 of file ObjectStorage.php.

References ObjectStorage\attach(), and ObjectStorage\getInfo().

attach (   $object,
  $information = null 
)

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

Parameters
object$objectThe object to add.
mixed$informationThe data to associate with the object.
Returns
void

Definition at line 220 of file ObjectStorage.php.

References ObjectStorage\offsetSet().

Referenced by ObjectStorage\addAll().

contains (   $object)

Checks if the storage contains a specific object.

Parameters
object$objectThe object to look for.
Returns
bool

Definition at line 208 of file ObjectStorage.php.

References ObjectStorage\offsetExists().

count ( )

Returns the number of objects in the storage.

Returns
int The number of objects in the storage.

Definition at line 140 of file ObjectStorage.php.

current ( )

Returns the current storage entry.

Returns
object The object at the current iterator position.

Definition at line 119 of file ObjectStorage.php.

Referenced by ObjectStorage\getInfo(), and ObjectStorage\valid().

detach (   $object)

Removes an object from the storage.

Parameters
object$objectThe object to remove.
Returns
void

Definition at line 231 of file ObjectStorage.php.

References ObjectStorage\offsetUnset().

Referenced by ObjectStorage\removeAll().

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.

Returns
array

Definition at line 308 of file ObjectStorage.php.

References ObjectStorage\toArray().

getInfo ( )

Returns the data, or info, associated with the object pointed by the current iterator position.

Returns
mixed The data associated with the current iterator position.

Definition at line 241 of file ObjectStorage.php.

References ObjectStorage\current().

Referenced by ObjectStorage\addAll().

getPosition (   $object)
Parameters
mixed$object
Returns
int|NULL

Definition at line 373 of file ObjectStorage.php.

isRelationDirty (   $object)

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

Parameters
mixed$object
Returns
bool

Definition at line 362 of file ObjectStorage.php.

key ( )

Returns the index at which the iterator currently is.

This is different from the SplObjectStorage as the key in this implementation is the object hash (string).

Returns
string The index corresponding to the position of the iterator.

Definition at line 109 of file ObjectStorage.php.

Referenced by ObjectStorage\setInfo().

next ( )

Moves to the next entry.

Returns
void

Definition at line 130 of file ObjectStorage.php.

offsetExists (   $object)

Checks whether an object exists in the storage.

Parameters
object$objectThe object to look for.
Returns
bool

Definition at line 167 of file ObjectStorage.php.

Referenced by ObjectStorage\contains().

offsetGet (   $object)

Returns the data associated with an object.

Parameters
object$objectThe object to look for.
Returns
mixed The data associated with an object in the storage.

Definition at line 197 of file ObjectStorage.php.

offsetSet (   $object,
  $information 
)

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

Parameters
object$objectThe object to add.
mixed$informationThe data to associate with the object.
Returns
void

Definition at line 152 of file ObjectStorage.php.

References ObjectStorage\$positionCounter.

Referenced by ObjectStorage\attach().

offsetUnset (   $object)

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

Parameters
object$objectThe object to remove.
Returns
void

Definition at line 178 of file ObjectStorage.php.

Referenced by ObjectStorage\detach().

removeAll ( ObjectStorage  $objectStorage)

Removes objects contained in another storage from the current storage.

Parameters
ObjectStorage$objectStorageThe storage containing the elements to remove.
Returns
void

Definition at line 279 of file ObjectStorage.php.

References ObjectStorage\detach().

rewind ( )

Rewinds the iterator to the first storage element.

Returns
void

Definition at line 87 of file ObjectStorage.php.

serialize ( )

Dummy method to avoid serialization.

Exceptions
RuntimeException
Returns
void

Definition at line 319 of file ObjectStorage.php.

setInfo (   $data)

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

Parameters
mixed$data
Returns
void

Definition at line 253 of file ObjectStorage.php.

References ObjectStorage\key().

toArray ( )

Returns this object storage as an array

Returns
array The object storage

Definition at line 291 of file ObjectStorage.php.

References ObjectStorage\$storage.

Referenced by ObjectStorage\getArray().

unserialize (   $serialized)

Dummy method to avoid unserialization.

Parameters
string$serialized
Exceptions
RuntimeException
Returns
void

Definition at line 331 of file ObjectStorage.php.

valid ( )

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

Returns
bool

Definition at line 97 of file ObjectStorage.php.

References ObjectStorage\current().

Member Data Documentation

$addedObjectsPositions = []
protected

Definition at line 64 of file ObjectStorage.php.

$isModified = false
protected

Definition at line 56 of file ObjectStorage.php.

Referenced by ObjectStorage\_isDirty().

$positionCounter = 0
protected

Definition at line 80 of file ObjectStorage.php.

Referenced by ObjectStorage\offsetSet().

$removedObjectsPositions = []
protected

Definition at line 72 of file ObjectStorage.php.

$storage = []
protected

Definition at line 49 of file ObjectStorage.php.

Referenced by ObjectStorage\toArray().

$warning = 'You should never see this warning. If you do, you probably used PHP array functions like current() on the TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage. To retrieve the first result, you can use the rewind() and current() methods.'
private

Definition at line 33 of file ObjectStorage.php.