class ReferenceManyCollection extends PersistentCollection (View source)

Property collection class.

This class stores all documents or their proxies referenced by a reference many property

Constants

INITIALIZED_NONE

INITIALIZED_FROM_COLLECTION

INITIALIZED_FROM_COLLECTION_FORCE

INITIALIZED_FROM_PHPCR

REFERENCE_TYPE_PATH

REFERENCE_TYPE_UUID

Properties

protected ArrayCollection $collection from PersistentCollection
protected bool $isDirty Whether the collection is dirty and needs to be synchronized with the database when the UnitOfWork that manages its persistent state commits. from PersistentCollection
protected string $initialized Whether the collection has already been initialized. from PersistentCollection
protected DocumentManagerInterface $dm from PersistentCollection
protected string $locale from PersistentCollection

Methods

bool
changed()

No description

takeSnapshot()

Reset original reference paths and mark the collection as non dirty.

ArrayCollection
unwrap()

No description

add($element)

{@inheritdoc}

clear()

{@inheritdoc}

contains($element)

{@inheritdoc}

containsKey($key)

{@inheritdoc}

count()

{@inheritdoc}

current()

{@inheritdoc}

exists(Closure $p)

{@inheritdoc}

filter(Closure $p)

{@inheritdoc}

first()

{@inheritdoc}

forAll(Closure $p)

{@inheritdoc}

get($key)

{@inheritdoc}

getIterator()

{@inheritdoc}

getKeys()

{@inheritdoc}

getValues()

{@inheritdoc}

indexOf($element)

{@inheritdoc}

isEmpty()

{@inheritdoc}

key()

{@inheritdoc}

last()

{@inheritdoc}

map(Closure $func)

{@inheritdoc}

next()

{@inheritdoc}

offsetExists($offset)

{@inheritdoc}

offsetGet($offset)

{@inheritdoc}

offsetSet($offset, $value)

{@inheritdoc}

offsetUnset($offset)

{@inheritdoc}

partition(Closure $p)

{@inheritdoc}

remove($key)

{@inheritdoc}

removeElement($element)

{@inheritdoc}

set($key, $value)

{@inheritdoc}

slice($offset, $length = null)

{@inheritdoc}

toArray()

{@inheritdoc}

string
__toString()

Returns a string representation of this object.

refresh()

Refresh the collection form the database, all local changes are lost.

bool
isInitialized()

Checks whether this collection has been initialized.

bool
isDirty()

Gets a boolean flag indicating whether this collection is dirty which means its state needs to be synchronized with the database.

setDirty(bool $dirty)

Sets a boolean flag, indicating whether this collection is dirty.

setLocale($locale)

Set the default locale for this collection.

initializeFromCollection(array|Collection $collection, bool $forceOverwrite = false)

No description

initialize()

Initializes the collection by loading its contents from the database if the collection is not yet initialized.

__construct(DocumentManagerInterface $dm, object $document, string $property, array $referencedNodes, string $targetDocument, string $locale = null, string $referenceType = self::REFERENCE_TYPE_UUID)

Creates a new persistent collection.

createFromCollection(DocumentManagerInterface $dm, object $document, string $property, array|Collection $collection, string $targetDocument, bool $forceOverwrite = false)

No description

array
getOriginalPaths()

Return the ordered list of references that existed when the collection was initialized.

Details

bool changed()

Return Value

bool Whether the collection was modified

takeSnapshot()

Reset original reference paths and mark the collection as non dirty.

ArrayCollection unwrap()

Return Value

ArrayCollection The collection

add($element)

{@inheritdoc}

Parameters

$element

clear()

{@inheritdoc}

contains($element)

{@inheritdoc}

Parameters

$element

containsKey($key)

{@inheritdoc}

Parameters

$key

count()

{@inheritdoc}

current()

{@inheritdoc}

exists(Closure $p)

{@inheritdoc}

Parameters

Closure $p

filter(Closure $p)

{@inheritdoc}

Parameters

Closure $p

first()

{@inheritdoc}

forAll(Closure $p)

{@inheritdoc}

Parameters

Closure $p

get($key)

{@inheritdoc}

Parameters

$key

getIterator()

{@inheritdoc}

getKeys()

{@inheritdoc}

getValues()

{@inheritdoc}

indexOf($element)

{@inheritdoc}

Parameters

$element

isEmpty()

{@inheritdoc}

key()

{@inheritdoc}

last()

{@inheritdoc}

map(Closure $func)

{@inheritdoc}

Parameters

Closure $func

next()

{@inheritdoc}

offsetExists($offset)

{@inheritdoc}

Parameters

$offset

offsetGet($offset)

{@inheritdoc}

Parameters

$offset

offsetSet($offset, $value)

{@inheritdoc}

Parameters

$offset
$value

offsetUnset($offset)

{@inheritdoc}

Parameters

$offset

partition(Closure $p)

{@inheritdoc}

Parameters

Closure $p

remove($key)

{@inheritdoc}

Parameters

$key

removeElement($element)

{@inheritdoc}

Parameters

$element

set($key, $value)

{@inheritdoc}

Parameters

$key
$value

slice($offset, $length = null)

{@inheritdoc}

Parameters

$offset
$length

toArray()

{@inheritdoc}

string __toString()

Returns a string representation of this object.

Return Value

string

refresh()

Refresh the collection form the database, all local changes are lost.

bool isInitialized()

Checks whether this collection has been initialized.

Return Value

bool

bool isDirty()

Gets a boolean flag indicating whether this collection is dirty which means its state needs to be synchronized with the database.

Return Value

bool TRUE if the collection is dirty, FALSE otherwise.

setDirty(bool $dirty)

Sets a boolean flag, indicating whether this collection is dirty.

Parameters

bool $dirty Whether the collection should be marked dirty or not.

setLocale($locale)

Set the default locale for this collection.

Parameters

$locale

protected initializeFromCollection(array|Collection $collection, bool $forceOverwrite = false)

Parameters

array|Collection $collection The collection to initialize with
bool $forceOverwrite If to force the database to be forced to the state of the collection

initialize()

Initializes the collection by loading its contents from the database if the collection is not yet initialized.

__construct(DocumentManagerInterface $dm, object $document, string $property, array $referencedNodes, string $targetDocument, string $locale = null, string $referenceType = self::REFERENCE_TYPE_UUID)

Creates a new persistent collection.

Parameters

DocumentManagerInterface $dm The DocumentManager the collection will be associated with.
object $document The document with the references property
string $property The node property name with the multivalued references
array $referencedNodes An array of referenced nodes (UUID or path)
string $targetDocument The class name of the target documents
string $locale The locale to use during the loading of this collection
string $referenceType Identifiers used for reference nodes in this collection, either path or default uuid

static ReferenceManyCollection createFromCollection(DocumentManagerInterface $dm, object $document, string $property, array|Collection $collection, string $targetDocument, bool $forceOverwrite = false)

Parameters

DocumentManagerInterface $dm The DocumentManager the collection will be associated with.
object $document The document with the references property
string $property The node property name with the multivalued references
array|Collection $collection The collection to initialize with
string $targetDocument The class name of the target documents
bool $forceOverwrite If to force the database to be forced to the state of the collection

Return Value

ReferenceManyCollection

array getOriginalPaths()

Return the ordered list of references that existed when the collection was initialized.

Return Value

array