l0wskilled / api-platform-traits
简化常用属性的使用的包
0.1.8
2020-04-21 10:26 UTC
Requires
- php: >=7.1
- api-platform/api-pack: ^1.2
Suggests
- doctrine/doctrine-bundle: to use the ORM extensions
- doctrine/mongodb-odm-bundle: to use the MongoDB ODM extensions
- stof/doctrine-extensions-bundle: to use the timestampable trait
This package is auto-updated.
Last update: 2024-09-29 05:28:57 UTC
README
简化api平台包所需常用属性的使用的包。
你可能想看看: https://github.com/epubli/api-platform-test
本包内容
- OrmIdentificatorTrait
- OrmTimestampableTrait
- OrmSoftDeletableTrait
- OdmIdentificatorTrait
- OdmTimestampableTrait
- OdmSoftDeletableTrait
ORM 时间戳和软删除的使用
添加stof doctrine扩展
composer require stof/doctrine-extensions-bundle
编辑配置文件 config/packages/stof_doctrine_extensions.yaml
它应该看起来像这样
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
softdeleteable: true
timestampable: true
以下是一个实现这些特性的示例类
use Epubli\ApiPlatform\TraitBundle\OrmSoftDeletableTrait;
use Epubli\ApiPlatform\TraitBundle\OrmTimestampableTrait;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=false)
*/
class Example
{
use OrmTimestampableTrait;
use OrmSoftDeletableTrait;
}