xanweb/c5-entity
最新稳定版本:v2.0
Composer 安装命令:
composer require xanweb/c5-entity
包简介
ConcreteCMS Entity
README 文档
README
Reusable classes for entities
Installation
Include library to your composer.json
composer require xanweb/c5-entity
Usage
Simply you can extend EntityService and EntityObject classes to benefit from predefined methods
use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="MyEntityTable") */ class MyEntity extends \Xanweb\C5\Entity\EntityObject { ... } /** * @method MyEntity createEntity() * @method MyEntity create($data) * @method MyEntity getByID($id) * @method MyEntity[] getList() * * or if your IDE supports generic type * @implements EntityService<MyEntity> */ class MyEntityService extends \Xanweb\C5\Entity\Service\EntityService { /** * {@inheritdoc} * * @see \Xanweb\C5\Entity\Service\EntityService::getEntityClass() */ public function getEntityClass(): string { return MyEntity::class; } }
Use TimeStampableTrait to include created date and last updated date fields to your entity.
Please note that usage of this trait requires "HasLifecycleCallbacks" annotation.
See https://www.doctrine-project.org/projects/doctrine-orm/en/2.8/reference/annotations-reference.html#annref_haslifecyclecallbacks
use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="MyEntityTable") * @ORM\HasLifecycleCallbacks */ class MyEntity extends \Xanweb\C5\Entity\EntityObject { use \Xanweb\C5\Entity\Traits\TimeStampableTrait; ... }
统计信息
- 总下载量: 397
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-03-24