geosocio / entity-utils
Utilities for Doctrine Entities
1.2.2
2018-02-19 13:01 UTC
Requires (Dev)
- doctrine/collections: ^1.0
- doctrine/orm: ^2.0
- phpunit/phpunit: ^6.2
- squizlabs/php_codesniffer: ^3.0
README
Provides simply Doctrine Entity Utilities.
Parameter Bag
Easily construct an entity through the constructor.
use GeoSocio\EntityUtils\ParameterBag; class User { __construct(array $data = []) { $params = new ParameterBag($data); $this->id = $params->getInt('id'); $this->first = $params->getString('first'); $this->last = $params->getString('last'); $this->address = $params->getInstance('address', Address::class, new Address()); $this->posts = $params->getCollection('posts', Post::class, new ArrayCollection()); } }
CreatedTrait
Include the trait in your entity to add a 'created' field that is added on persist.
use GeoSocio\EntityUtils\CreatedTrait; class User { use CreatedTrait; }