TYPO3 CMS  TYPO3_7-6
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 ()
 
 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 339 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.

Returns
void

Implements TYPO3\CMS\Extbase\Persistence\ObjectMonitoringInterface.

Definition at line 329 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
Returns
void

Definition at line 266 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.
Returns
void

Definition at line 220 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 208 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 140 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 119 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.
Returns
void

Definition at line 231 of file ObjectStorage.php.

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

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

◆ 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 241 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 361 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 350 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 109 of file ObjectStorage.php.

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

◆ next()

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

Moves to the next entry.

Returns
void

Definition at line 130 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 167 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 197 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.
Returns
void

Definition at line 152 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.
Returns
void

Definition at line 178 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.
Returns
void

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

Returns
void

Definition at line 87 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
Returns
void

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

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

◆ unserialize()

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

Dummy method to avoid unserialization.

Parameters
string$serialized
Exceptions

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