setono/doctrine-object-manager-trait
最新稳定版本:v1.3.0
Composer 安装命令:
composer require setono/doctrine-object-manager-trait
包简介
A very simple library that offers an object manager trait to get the object manager for a given class
README 文档
README
If you are like and me and usually don't inject entity managers directly, but inject the manager registry instead then this little library will come in handy.
Installation
$ composer require setono/doctrine-object-manager-trait
Usage
<?php use Doctrine\Persistence\ManagerRegistry; use Setono\DoctrineObjectManagerTrait\ORM\ORMManagerTrait; final class YourClass { use ORMManagerTrait; public function __construct(ManagerRegistry $managerRegistry) { $this->managerRegistry = $managerRegistry; } public function someMethod(): void { /** * $entity is an entity managed by Doctrine or a class-string representing an entity managed by Doctrine */ $entity = ; /** * Because we used the ORMManagerTrait above the getManager method will return an EntityManagerInterface * * @var \Doctrine\ORM\EntityManagerInterface $manager */ $manager = $this->getManager($entity); $manager->persist($entity); $manager->flush(); } }
统计信息
- 总下载量: 147.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 14
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-05-07