<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rekalogika / doctrine-collections-decorator example snippets
use Doctrine\Common\Collections\Collection;
use Rekalogika\Collections\Decorator\AbstractCollectionDecorator;
/**
* @extends AbstractCollectionDecorator<array-key,Book>
*/
class BookCollection extends AbstractCollectionDecorator
{
/**
* @param Collection<array-key,Book> $collection
*/
public function __construct(private Collection $collection)
{
}
protected function getWrapped(): Collection
{
return $this->collection;
}
// add and override methods here:
// ...
}
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity()]
class BookShelf
{
/**
* @var Collection<array-key,Book>
*/
#[ORM\OneToMany(targetEntity: Book::class)]
private Collection $books;
public function __construct()
{
$this->books = new ArrayCollection();
}
public function getBooks(): BookCollection
{
return new BookCollection($this->bookskkk);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.