承接 rekalogika/doctrine-collections-decorator 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rekalogika/doctrine-collections-decorator

最新稳定版本:2.3.0

Composer 安装命令:

composer require rekalogika/doctrine-collections-decorator

包简介

Lets you easily create decorator classes to dynamically modify the behaviors of Doctrine Collection objects, including the collection objects used by Doctrine ORM in your entities.

README 文档

README

Lets you easily create decorator classes to dynamically modify the behaviors of Doctrine Collection objects, including the collection objects used by Doctrine ORM in your entities.

Motivation

Custom collection classes won't come to Doctrine ORM anytime soon. Therefore, the only way to modify the behavior of a Doctrine collection is to use decorators. However, creating a Collection decorator by hand is a tedious process.

Synopsis

The decorator class extending one of our abstract classes:

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: // ... }

The usage in an entity:

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); } }

Documentation

rekalogika.dev/doctrine-collections-decorator

License

MIT

Contributing

Issues and pull requests should be filed in the GitHub repository rekalogika/doctrine-collections-decorator.

统计信息

  • 总下载量: 50.73k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04