‪TYPO3CMS  11.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 TYPO3\CMS\Extbase\Persistence\Generic\LazyObjectStorage

Public Member Functions

 rewind ()
 
bool valid ()
 
string key ()
 
TEntity null 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)
 
list< TEntity > toArray ()
 
list< TEntity > 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.

@template TEntity <string, TEntity> <string, TEntity>

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

Referenced by TYPO3\CMS\Extbase\Utility\DebuggerUtility\renderHeader().

◆ _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 355 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<TEntity>‪$objectStorage

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

Definition at line 284 of file ObjectStorage.php.

◆ attach()

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

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

Parameters
TEntity$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 240 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\addAll().

◆ contains()

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

Checks if the storage contains a specific object.

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

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

Definition at line 229 of file ObjectStorage.php.

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

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\count().

◆ current()

◆ detach()

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

Removes an object from the storage.

Parameters
TEntity$object‪The object to remove.

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

Definition at line 250 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\removeAll().

◆ getArray()

list<TEntity> 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
‪list<TEntity>

Definition at line 325 of file ObjectStorage.php.

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

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\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 387 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Backend\persistObjectStorage().

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

Referenced by TYPO3\CMS\Extbase\Persistence\Generic\Backend\persistObjectStorage().

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

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\key(), and TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\setInfo().

◆ next()

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

◆ offsetExists()

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

Checks whether an object exists in the storage.

Parameters
TEntity | 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 173 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\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
TEntity | 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 213 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\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
TEntity$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 157 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\attach().

◆ offsetUnset()

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

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

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

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

Definition at line 185 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\detach().

◆ removeAll()

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

Removes objects contained in another storage from the current storage.

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

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

Definition at line 296 of file ObjectStorage.php.

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

◆ serialize()

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

Dummy method to avoid serialization.

Exceptions

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

◆ toArray()

list<TEntity> TYPO3\CMS\Extbase\Persistence\ObjectStorage::toArray ( )

Returns this object storage as an array

Returns
‪list<TEntity>

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

Definition at line 308 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\getArray().

◆ unserialize()

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

Dummy method to avoid unserialization.

Exceptions

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

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 unset when the object gets removed from the objectstorage

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

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\_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 reset, when all objects will be removed from the objectstorage

Definition at line 82 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\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 75 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 55 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< TYPO3\CMS\Beuser\Domain\Model\BackendUserGroup >\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 40 of file ObjectStorage.php.