| Methods |
public
|
__construct(EntityManagerInterface $em, ClassMetadata $class, Collection<TKey, T>&Selectable<TKey, T> $collection)
Creates a new persistent collection.
Creates a new persistent collection.
Parameters
| $em |
The EntityManager the collection will be associated with.
|
| $class |
The class descriptor of the entity type of this collection.
|
| $collection |
The collection elements.
|
|
#
|
public
|
setOwner(object $entity, AssociationMapping $assoc): void
INTERNAL:
Sets the collection's owning entity together with the AssociationMapping that
describes the association…
INTERNAL:
Sets the collection's owning entity together with the AssociationMapping that
describes the association between the owner and the elements of the collection.
|
#
|
public
|
getOwner(): object|null
INTERNAL:
Gets the collection owner.
INTERNAL:
Gets the collection owner.
|
#
|
public
|
getTypeClass(): ClassMetadata
|
#
|
private
|
getUnitOfWork(): UnitOfWork
|
#
|
public
|
hydrateAdd(mixed $element): void
INTERNAL:
Adds an element to a collection during hydration. This will automatically
complete bidirectional associations…
INTERNAL:
Adds an element to a collection during hydration. This will automatically
complete bidirectional associations in the case of a one-to-many association.
Parameters
| $element |
The element to add.
|
|
#
|
public
|
hydrateSet(mixed $key, mixed $element): void
INTERNAL:
Sets a keyed element in the collection during hydration.
INTERNAL:
Sets a keyed element in the collection during hydration.
Parameters
| $key |
The key to set.
|
| $element |
The element to set.
|
|
#
|
public
|
initialize(): void
Initializes the collection by loading its contents from the database
if the collection is not yet initialized.
Initializes the collection by loading its contents from the database
if the collection is not yet initialized.
Overrides
|
#
|
public
|
takeSnapshot(): void
INTERNAL:
Tells this collection to take a snapshot of its current state.
INTERNAL:
Tells this collection to take a snapshot of its current state.
|
#
|
public
|
getSnapshot(): array
INTERNAL:
Returns the last snapshot of the elements in the collection.
INTERNAL:
Returns the last snapshot of the elements in the collection.
|
#
|
public
|
getDeleteDiff(): mixed[]
INTERNAL:
getDeleteDiff
|
#
|
public
|
getInsertDiff(): mixed[]
INTERNAL:
getInsertDiff
|
#
|
public
|
getMapping(): array
INTERNAL: Gets the association mapping of the collection.
INTERNAL: Gets the association mapping of the collection.
|
#
|
private
|
changed(): void
Marks this collection as changed/dirty.
Marks this collection as changed/dirty.
|
#
|
public
|
isDirty(): bool
Gets a boolean flag indicating whether this collection is dirty which means
its state needs to be synchronized with the…
Gets a boolean flag indicating whether this collection is dirty which means
its state needs to be synchronized with the database.
Returns
TRUE if the collection is dirty, FALSE otherwise.
|
#
|
public
|
setDirty(bool $dirty): void
Sets a boolean flag, indicating whether this collection is dirty.
Sets a boolean flag, indicating whether this collection is dirty.
Parameters
| $dirty |
Whether the collection should be marked dirty or not.
|
|
#
|
public
|
setInitialized(bool $bool): void
Sets the initialized flag of the collection, forcing it into that state.
Sets the initialized flag of the collection, forcing it into that state.
|
#
|
public
|
remove($key)
{@inheritDoc}
Returns
The removed element or NULL, if the collection did not contain the element.
Overrides
|
#
|
public
|
removeElement($element): bool
{@inheritDoc}
Returns
TRUE if this collection contained the specified element, FALSE otherwise.
Overrides
|
#
|
public
|
containsKey($key): bool
{@inheritDoc}
Returns
TRUE if the collection contains an element with the specified key/index,
FALSE otherwise.
Overrides
|
#
|
public
|
contains<TMaybeContained>($element): bool
{@inheritDoc}
Returns
TRUE if the collection contains the element, FALSE otherwise.
Overrides
|
#
|
public
|
get($key)
{@inheritDoc}
|
#
|
public
|
count(): int
{@inheritDoc}
|
#
|
public
|
set($key, $value): void
{@inheritDoc}
|
#
|
public
|
add($value): bool
{@inheritDoc}
Returns
we will require a native return type declaration in 3.0
Overrides
|
#
|
public
|
offsetExists($offset): bool
{@inheritDoc}
|
#
|
public
|
offsetGet($offset)
{@inheritDoc}
|
#
|
public
|
offsetSet($offset, $value): void
{@inheritDoc}
|
#
|
public
|
offsetUnset($offset): object|null
{@inheritDoc}
|
#
|
public
|
isEmpty(): bool
{@inheritDoc}
Returns
TRUE if the collection is empty, FALSE otherwise.
Overrides
|
#
|
public
|
clear(): void
{@inheritDoc}
|
#
|
public
|
__sleep(): string[]
Called by PHP when this collection is serialized. Ensures that only the
elements are properly serialized.
Called by PHP when this collection is serialized. Ensures that only the
elements are properly serialized.
Internal note: Tried to implement Serializable first but that did not work well
with circular references. This solution seems simpler and works well.
|
#
|
public
|
slice(int $offset, int|null $length = null): mixed[]
Extracts a slice of $length elements starting at position $offset from the Collection.
Extracts a slice of $length elements starting at position $offset from the Collection.
If $length is null it returns all elements from $offset to the end of the Collection.
Keys have to be preserved by this method. Calling this method will only return the
selected slice and NOT change the elements contained in the collection slice is called on.
Parameters
| $offset |
The offset to start from.
|
| $length |
The maximum number of elements to return, or null for no limit.
|
Overrides
|
#
|
public
|
__clone()
Cleans up internal state of cloned persistent collection.
Cleans up internal state of cloned persistent collection.
The following problems have to be prevented:
- Added entities are added to old PC
- New collection is not dirty, if reused on other entity nothing
changes.
- Snapshot leads to invalid diffs being generated.
- Lazy loading grabs entities from old owner object.
- New collection is connected to old owner and leads to duplicate keys.
|
#
|
public
|
matching(Criteria $criteria): Collection
Selects all elements from a selectable that match the expression and
return a new collection containing these elements.
Selects all elements from a selectable that match the expression and
return a new collection containing these elements.
Throws
Implements
|
#
|
public
|
unwrap(): Collection<TKey, T>&Selectable<TKey, T>
Retrieves the wrapped Collection instance.
Retrieves the wrapped Collection instance.
|
#
|
protected
|
doInitialize(): void
Do the initialization logic
Do the initialization logic
Implements
|
#
|
private
|
restoreNewObjectsInDirtyCollection(object[] $newObjects): void
|
#
|