geosocio / entity-utils
Utilities for Doctrine Entities
Installs: 251
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/geosocio/entity-utils
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; }