class ChildrenCollection extends PersistentCollection (View source)

Children collection class.

This class represents a collection of children of a document which phpcr names match a optional filter

Constants

INITIALIZED_NONE

INITIALIZED_FROM_COLLECTION

INITIALIZED_FROM_COLLECTION_FORCE

INITIALIZED_FROM_PHPCR

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 originalNodeNames 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|array $filter = null, int $fetchDepth = -1, string $locale = null)

Creates a new persistent collection.

createFromCollection(DocumentManagerInterface $dm, object $document, array|Collection $collection, string|array $filter = null, int $fetchDepth = -1, bool $forceOverwrite = false)

No description

array
getOriginalNodeNames()

Return the ordered list of node names of children that existed when the collection was initialized.

Details

bool changed()

Return Value

bool Whether the collection was modified

takeSnapshot()

Reset originalNodeNames 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|array $filter = null, int $fetchDepth = -1, string $locale = null)

Creates a new persistent collection.

Parameters

DocumentManagerInterface $dm The DocumentManager the collection will be associated with.
object $document The parent document instance
string|array $filter Filter string or array of filter string
int $fetchDepth Optional fetch depth, -1 to not override.
string $locale The locale to use during the loading of this collection

static ChildrenCollection createFromCollection(DocumentManagerInterface $dm, object $document, array|Collection $collection, string|array $filter = null, int $fetchDepth = -1, bool $forceOverwrite = false)

Parameters

DocumentManagerInterface $dm The DocumentManager the collection will be associated with.
object $document The parent document instance
array|Collection $collection The collection to initialize with
string|array $filter Filter string or array of filter string
int $fetchDepth Optional fetch depth, -1 to not override.
bool $forceOverwrite If to force overwrite the state in the database to the state of the collection

Return Value

ChildrenCollection

array getOriginalNodeNames()

Return the ordered list of node names of children that existed when the collection was initialized.

Return Value

array