CoolCMS API

CollectionOf
in package

FinalYes

Declares the item type of a `Collection` or `array` property for {@see \App\Core\Utils\Hydrators\EntityHydrator}.

The module hydrator does not read Doctrine attributes and the type hint carries no item type, so this attribute supplies it. With owned = true (cascade persist plus orphan removal, e.g. translations) extract() serializes the children with full data so the Api save can insert and update them. With owned = false (default, typically many-to-many) only {id: ...} references are emitted and the child is looked up from _references.

Usage:

#[CollectionOf(PageText::class, owned: true)]
protected Collection $translations;
Attributes
#[Attribute]
\Attribute::TARGET_PROPERTY

Table of Contents

Properties

$itemClass  : string
$owned  : bool

Methods

__construct()  : mixed

Properties

Methods

__construct()

public __construct(class-string $itemClass[, bool $owned = false ]) : mixed
Parameters
$itemClass : class-string

item class of the collection or array

$owned : bool = false

owned cascade collection (full child data inline in extract())

On this page

Search results