‪TYPO3CMS  9.5
TYPO3\CMS\Extbase\Persistence\ObjectStorage Class Reference
Inheritance diagram for TYPO3\CMS\Extbase\Persistence\ObjectStorage:
TYPO3\CMS\Extbase\Persistence\ObjectMonitoringInterface TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage

Public Member Functions

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

Protected Attributes

array $storage = array( )
 
bool $isModified = false
 
array $addedObjectsPositions = array( )
 
array $removedObjectsPositions = array( )
 
int $positionCounter = 0
 

Private Attributes

string $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 25 of file ObjectStorage.php.

Member Function Documentation

◆ _isDirty()

bool TYPO3\CMS\Extbase\Persistence\ObjectStorage::_isDirty ( )

Returns TRUE if the storage was modified after reconstitution.

Returns
‪bool

Implements TYPO3\CMS\Extbase\Persistence\ObjectMonitoringInterface.

Definition at line 344 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\$isModified.

◆ _memorizeCleanState()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::_memorizeCleanState ( )

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

Implements TYPO3\CMS\Extbase\Persistence\ObjectMonitoringInterface.

Definition at line 334 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage\initialize().

◆ addAll()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::addAll ( ObjectStorage  $objectStorage)

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

Parameters
ObjectStorage$objectStorage

Definition at line 265 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\attach(), and TYPO3\CMS\Extbase\Persistence\ObjectStorage\getInfo().

◆ attach()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::attach (   $object,
  $information = null 
)

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

Parameters
object$object‪The object to add.
mixed$information‪The data to associate with the object.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 222 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\offsetSet().

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\addAll().

◆ contains()

bool TYPO3\CMS\Extbase\Persistence\ObjectStorage::contains (   $object)

Checks if the storage contains a specific object.

Parameters
object$object‪The object to look for.
Returns
‪bool

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 211 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\offsetExists().

◆ count()

int TYPO3\CMS\Extbase\Persistence\ObjectStorage::count ( )

Returns the number of objects in the storage.

Returns
‪int The number of objects in the storage.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 132 of file ObjectStorage.php.

◆ current()

object TYPO3\CMS\Extbase\Persistence\ObjectStorage::current ( )

Returns the current storage entry.

Returns
‪object The object at the current iterator position.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 113 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\getInfo(), and TYPO3\CMS\Extbase\Persistence\ObjectStorage\valid().

◆ detach()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::detach (   $object)

Removes an object from the storage.

Parameters
object$object‪The object to remove.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 232 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\offsetUnset().

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\removeAll().

◆ getArray()

array TYPO3\CMS\Extbase\Persistence\ObjectStorage::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 306 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\toArray().

◆ getInfo()

mixed TYPO3\CMS\Extbase\Persistence\ObjectStorage::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 242 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\current().

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\addAll().

◆ getPosition()

int null TYPO3\CMS\Extbase\Persistence\ObjectStorage::getPosition (   $object)
Parameters
mixed$object
Returns
‪int|null

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 366 of file ObjectStorage.php.

◆ isRelationDirty()

bool TYPO3\CMS\Extbase\Persistence\ObjectStorage::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 355 of file ObjectStorage.php.

◆ key()

string TYPO3\CMS\Extbase\Persistence\ObjectStorage::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.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 103 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\setInfo().

◆ next()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::next ( )

Moves to the next entry.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 122 of file ObjectStorage.php.

◆ offsetExists()

bool TYPO3\CMS\Extbase\Persistence\ObjectStorage::offsetExists (   $value)

Checks whether an object exists in the storage.

Parameters
object | int$value‪The object to look for, or the key in the storage.
Returns
‪bool

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 158 of file ObjectStorage.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\contains().

◆ offsetGet()

mixed TYPO3\CMS\Extbase\Persistence\ObjectStorage::offsetGet (   $value)

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

Parameters
object | int$value‪The object to look for, or its key in the storage.
Returns
‪mixed The data associated with an object in the storage, or the object itself if an integer is passed.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 196 of file ObjectStorage.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger().

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\offsetUnset().

◆ offsetSet()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::offsetSet (   $object,
  $information 
)

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

Parameters
object$object‪The object to add.
mixed$information‪The data to associate with the object.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 143 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\$positionCounter.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\attach().

◆ offsetUnset()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::offsetUnset (   $value)

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

Parameters
object | int$value‪The object to remove, or its key in the storage.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 169 of file ObjectStorage.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), and TYPO3\CMS\Extbase\Persistence\ObjectStorage\offsetGet().

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\detach().

◆ removeAll()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::removeAll ( ObjectStorage  $objectStorage)

Removes objects contained in another storage from the current storage.

Parameters
ObjectStorage$objectStorage‪The storage containing the elements to remove.

Definition at line 277 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\detach().

◆ rewind()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::rewind ( )

Rewinds the iterator to the first storage element.

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 81 of file ObjectStorage.php.

◆ serialize()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::serialize ( )

Dummy method to avoid serialization.

Exceptions

Definition at line 316 of file ObjectStorage.php.

◆ setInfo()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::setInfo (   $data)

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

Parameters
mixed$data

Definition at line 253 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\key().

◆ toArray()

array TYPO3\CMS\Extbase\Persistence\ObjectStorage::toArray ( )

Returns this object storage as an array

Returns
‪array The object storage

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 289 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\$storage.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\getArray().

◆ unserialize()

TYPO3\CMS\Extbase\Persistence\ObjectStorage::unserialize ( )

Dummy method to avoid unserialization.

Exceptions

Definition at line 326 of file ObjectStorage.php.

◆ valid()

bool TYPO3\CMS\Extbase\Persistence\ObjectStorage::valid ( )

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

Returns
‪bool

Reimplemented in TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage.

Definition at line 91 of file ObjectStorage.php.

References TYPO3\CMS\Extbase\Persistence\ObjectStorage\current().

Member Data Documentation

◆ $addedObjectsPositions

array TYPO3\CMS\Extbase\Persistence\ObjectStorage::$addedObjectsPositions = array( )
protected

An array holding the internal position the object was added. The object entry is unsetted when the object gets removed from the objectstorage

Definition at line 62 of file ObjectStorage.php.

◆ $isModified

bool TYPO3\CMS\Extbase\Persistence\ObjectStorage::$isModified = false
protected

A flag indication if the object storage was modified after reconstitution (eg. by adding a new object)

Definition at line 55 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\_isDirty().

◆ $positionCounter

int TYPO3\CMS\Extbase\Persistence\ObjectStorage::$positionCounter = 0
protected

An internal var holding the count of added objects to be stored as position. It would be resetted, when all objects will be removed from the objectstorage

Definition at line 76 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage\offsetSet().

◆ $removedObjectsPositions

array TYPO3\CMS\Extbase\Persistence\ObjectStorage::$removedObjectsPositions = array( )
protected

An array holding the internal position the object was added before, when it would be removed from the objectstorage

Definition at line 69 of file ObjectStorage.php.

◆ $storage

array TYPO3\CMS\Extbase\Persistence\ObjectStorage::$storage = array( )
protected

An array holding the objects and the stored information. The key of the array items ist the spl_object_hash of the given object.

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

Definition at line 49 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage\addAll(), TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage\removeAll(), and TYPO3\CMS\Extbase\Persistence\ObjectStorage\toArray().

◆ $warning

string TYPO3\CMS\Extbase\Persistence\ObjectStorage::$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

This field is only needed to make debugging easier: If you call current() on a class that implements Iterator, PHP will return the first field of the object instead of calling the current() method of the interface. We use this unusual behavior of PHP to return the warning below in this case.

Definition at line 34 of file ObjectStorage.php.