Class CollectionOf
Attribute to specify the DTO class for array collections.
Since PHP doesn't have runtime generics, this attribute tells the DtoMapper what type of DTO to create for each element in an array.
Example
readonly class ArticleDto {
public function __construct(
public int $id,
public string $title,
#[CollectionOf(CommentDto::class)]
public array $comments = [],
) {}
}
Namespace: Cake\ORM\Attribute
Method Summary
-
__construct() public
Method Detail
__construct() ΒΆ public
__construct(class-string $class)
Parameters
-
class-string$class The DTO class for collection elements