Doctrine\ORM\PersistentCollection
A PersistentCollection represents a collection of elements that have persistent state.
Collections of entities represent only the associations (links) to those entities.
That means, if the collection is part of a many-many mapping and you remove
entities from the collection, only the links in the relation table are removed (on flush).
Similarly, if you remove entities from a collection that is part of a one-many
mapping this will only result in the nulling out of the foreign keys on flush.
- Author: Konsta Vesterinen <kvesteri@cc.hut.fi>
Synopsis
class PersistentCollection
implements
Collection,Selectable
{
- // members
- private array $snapshot;
- private $owner;
- private array $association;
- private EntityManager $em;
- private string $backRefFieldName;
- private $typeClass;
- private boolean $isDirty;
- private boolean $initialized;
- private Collection $coll;
- // methods
- public void __construct()
- public void setOwner()
- public getOwner()
- public void getTypeClass()
- public void hydrateAdd()
- public void hydrateSet()
- public void initialize()
- public void takeSnapshot()
- public array getSnapshot()
- public array getDeleteDiff()
- public array getInsertDiff()
- public array getMapping()
- private void changed()
- public boolean isDirty()
- public void setDirty()
- public void setInitialized()
- public boolean isInitialized()
- public void first()
- public void last()
- public void remove()
- public void removeElement()
- public void containsKey()
- public void contains()
- public void exists()
- public void indexOf()
- public void get()
- public void getKeys()
- public void getValues()
- public void count()
- public void set()
- public void add()
- public void isEmpty()
- public void getIterator()
- public void map()
- public void filter()
- public void forAll()
- public void partition()
- public void toArray()
- public void clear()
- public void __sleep()
- public void offsetExists()
- public void offsetGet()
- public void offsetSet()
- public void offsetUnset()
- public void key()
- public void current()
- public void next()
- public Collection unwrap()
- public array slice()
- public void __clone()
- public Collection matching()
Hierarchy
Tasks
Line | Task |
---|---|
48+ | Design for inheritance to allow custom implementations? |
382 | If the keys are persistent as well (not yet implemented) |
Members
private
- $association
—
array
The association mapping the collection belongs to. - $backRefFieldName
—
string
The name of the field on the target entities that points to the owner of the collection. This is only set if the association is bi-directional. - $coll
—
Doctrine\Common\Collections\Collection
The wrapped Collection instance. - $em
—
\Doctrine\ORM\EntityManager
The EntityManager that manages the persistence of the collection. - $initialized
—
boolean
Whether the collection has already been initialized. - $isDirty
—
boolean
Whether the collection is dirty and needs to be synchronized with the database when the UnitOfWork that manages its persistent state commits. - $owner
—
The entity that owns this collection. - $snapshot
—
array
A snapshot of the collection at the moment it was fetched from the database. -
$typeClass
The class descriptor of the collection's entity type.
Methods
private
- changed() — Marks this collection as changed/dirty.
public
- __construct() — Creates a new persistent collection.
- __clone() — Cleanup internal state of cloned persistent collection.
- __sleep() — Called by PHP when this collection is serialized. Ensures that only the elements are properly serialized.
- add() — {@inheritdoc}
- clear() — {@inheritdoc}
- contains() — {@inheritdoc}
- containsKey() — {@inheritdoc}
- count() — {@inheritdoc}
- current() — Gets the element of the collection at the current iterator position.
- exists() — {@inheritdoc}
- filter() — {@inheritdoc}
- first() — {@inheritdoc}
- forAll() — {@inheritdoc}
- get() — {@inheritdoc}
- getDeleteDiff() — INTERNAL: getDeleteDiff
- getInsertDiff() — INTERNAL: getInsertDiff
- getIterator() — {@inheritdoc}
- getKeys() — {@inheritdoc}
- getMapping() — INTERNAL: Gets the association mapping of the collection.
- getOwner() — INTERNAL: Gets the collection owner.
- getSnapshot() — INTERNAL: Returns the last snapshot of the elements in the collection.
- getTypeClass()
- getValues() — {@inheritdoc}
- hydrateAdd() — INTERNAL: Adds an element to a collection during hydration. This will automatically complete bidirectional associations in the case of a one-to-many association.
- hydrateSet() — INTERNAL: Sets a keyed element in the collection during hydration.
- indexOf() — {@inheritdoc}
- initialize() — Initializes the collection by loading its contents from the database if the collection is not yet initialized.
- isDirty() — Gets a boolean flag indicating whether this collection is dirty which means its state needs to be synchronized with the database.
- isEmpty() — {@inheritdoc}
- isInitialized() — Checks whether this collection has been initialized.
- key()
- last() — {@inheritdoc}
- map() — {@inheritdoc}
- matching() — Select all elements from a selectable that match the expression and return a new collection containing these elements.
- next() — Moves the internal iterator position to the next element.
- offsetExists()
- offsetGet()
- offsetSet()
- offsetUnset()
- partition() — {@inheritdoc}
- remove() — {@inheritdoc}
- removeElement() — {@inheritdoc}
- set() — {@inheritdoc}
- setDirty() — Sets a boolean flag, indicating whether this collection is dirty.
- setInitialized() — Sets the initialized flag of the collection, forcing it into that state.
- setOwner() — INTERNAL: Sets the collection's owning entity together with the AssociationMapping that describes the association between the owner and the elements of the collection.
- slice() — Extract a slice of $length elements starting at position $offset from the Collection.
- takeSnapshot() — INTERNAL: Tells this collection to take a snapshot of its current state.
- toArray() — {@inheritdoc}
- unwrap() — Retrieves the wrapped Collection instance.