l0wskilled / api-platform-traits
Package to ease the use of common properties
Installs: 1 643
Dependents: 1
Suggesters: 1
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
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: 2025-03-01 00:29:26 UTC
README
Package to ease the use of common properties needed for the api platform package.
You may want to have a look at: https://github.com/epubli/api-platform-test
Content of this package
- OrmIdentificatorTrait
- OrmTimestampableTrait
- OrmSoftDeletableTrait
- OdmIdentificatorTrait
- OdmTimestampableTrait
- OdmSoftDeletableTrait
Usage of ORM Timestampable and SoftDeletable
Add the stof doctrine extension:
composer require stof/doctrine-extensions-bundle
Edit the config file config/packages/stof_doctrine_extensions.yaml
It should look like this:
stof_doctrine_extensions:
default_locale: en_US
orm:
default:
softdeleteable: true
timestampable: true
Here is an example class which implements these traits:
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;
}