‪TYPO3CMS  10.4
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 ()
 
DomainObjectInterface 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 27 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 347 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 337 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

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

Definition at line 268 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
DomainObjectInterface$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 225 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\addAll().

◆ contains()

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

Checks if the storage contains a specific object.

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

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

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

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\count().

◆ current()

◆ detach()

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

Removes an object from the storage.

Parameters
DomainObjectInterface$object‪The object to remove.

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

Definition at line 235 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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 309 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 245 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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 369 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 358 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 105 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\key(), and TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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
DomainObjectInterface | 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 160 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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
DomainObjectInterface | 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 198 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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
DomainObjectInterface$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 145 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\attach().

◆ offsetUnset()

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

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

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

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

Definition at line 171 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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.

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

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

◆ serialize()

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

Dummy method to avoid serialization.

Exceptions

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

◆ toArray()

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

◆ unserialize()

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

Dummy method to avoid unserialization.

Exceptions

Definition at line 329 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 93 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 64 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 57 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\_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 78 of file ObjectStorage.php.

Referenced by TYPO3\CMS\Extbase\Persistence\ObjectStorage< TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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 71 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 51 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\Extbase\Tests\Unit\Reflection\Fixture\DummyClassWithAllTypesOfProperties >\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 36 of file ObjectStorage.php.