TYPO3 CMS  TYPO3_8-7
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 ()
 
 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()

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 336 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 326 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 256 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$objectThe object to add.
mixed$informationThe data to associate with the object.

Definition at line 213 of file ObjectStorage.php.

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

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

◆ contains()

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

Checks if the storage contains a specific object.

Parameters
object$objectThe object to look for.
Returns
bool

Definition at line 202 of file ObjectStorage.php.

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

◆ count()

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

Returns the number of objects in the storage.

Returns
int The number of objects in the storage.

Definition at line 136 of file ObjectStorage.php.

◆ current()

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

Returns the current storage entry.

Returns
object The object at the current iterator position.

Definition at line 117 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$objectThe object to remove.

Definition at line 223 of file ObjectStorage.php.

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

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

◆ getArray()

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 297 of file ObjectStorage.php.

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

◆ getInfo()

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 233 of file ObjectStorage.php.

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

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

◆ getPosition()

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

Definition at line 358 of file ObjectStorage.php.

◆ isRelationDirty()

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 347 of file ObjectStorage.php.

◆ key()

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.

Definition at line 107 of file ObjectStorage.php.

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

◆ next()

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

Moves to the next entry.

Definition at line 126 of file ObjectStorage.php.

◆ offsetExists()

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

Checks whether an object exists in the storage.

Parameters
object$objectThe object to look for.
Returns
bool

Definition at line 162 of file ObjectStorage.php.

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

◆ offsetGet()

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

◆ 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$objectThe object to add.
mixed$informationThe data to associate with the object.

Definition at line 147 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 (   $object)

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

Parameters
object$objectThe object to remove.

Definition at line 172 of file ObjectStorage.php.

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$objectStorageThe storage containing the elements to remove.

Definition at line 268 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.

Definition at line 85 of file ObjectStorage.php.

◆ serialize()

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

Dummy method to avoid serialization.

Exceptions

Definition at line 307 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 244 of file ObjectStorage.php.

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

◆ toArray()

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

Returns this object storage as an array

Returns
array The object storage

Definition at line 280 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 (   $serialized)

Dummy method to avoid unserialization.

Parameters
string$serialized
Exceptions

Definition at line 318 of file ObjectStorage.php.

◆ valid()

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

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

Returns
bool

Definition at line 95 of file ObjectStorage.php.

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

Member Data Documentation

◆ $addedObjectsPositions

TYPO3\CMS\Extbase\Persistence\ObjectStorage::$addedObjectsPositions = []
protected

Definition at line 64 of file ObjectStorage.php.

◆ $isModified

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

◆ $positionCounter

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

◆ $removedObjectsPositions

TYPO3\CMS\Extbase\Persistence\ObjectStorage::$removedObjectsPositions = []
protected

Definition at line 72 of file ObjectStorage.php.

◆ $storage

TYPO3\CMS\Extbase\Persistence\ObjectStorage::$storage = []
protected

◆ $warning

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

Definition at line 33 of file ObjectStorage.php.