Download the PHP package xactsystems/type-hint-hydrator without Composer
On this page you can find all versions of the php package xactsystems/type-hint-hydrator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xactsystems/type-hint-hydrator
More information about xactsystems/type-hint-hydrator
Files in xactsystems/type-hint-hydrator
Package type-hint-hydrator
Short Description A Symfony object hydrator based on declared types and annotation type-hints.
License MIT
Informations about the package type-hint-hydrator
type-hint-hydrator
A Symfony Type Hint hydrator that uses declared types and @var annotations to determine the hydrated type. Under the hood it uses the laminas-hydrator for the mapping process. See https://github.com/laminas/laminas-hydrator/
It can handle request objects and arrays of data to hydrate annotated classes and arrays etc. It can also validate against any Assert annotations the hydrated object may contain.
If properties of the hydrated object are annotated as Doctrine Entities, the hydrator will attempt to load the entity for the key value provided. We currently don't support composite keys.
Documentation
1) Add the type-hint-hydrator to your project
2) Add the bundle to your configuration file
If you are using Symfony 4 onwards and using Flex you can skip this step.
Symfony 4.4 onwards - bundles.php
3) Declare types or annotate your hydrated object properties
4) Hydrate your object in your controller
Or to update and existing entity:
5) Smile and be happy
It really is that easy. No more form types! Annotate your objects correctly with types and assertions, make sure your submitted forms use the same names as your object proprieties and it will just work!
Create proper Model classes for your data and hydrate them, and let them do the work a proper MVC model should.
Methods
hydrateObject
Hydrate an object from an array of values. If $validate is true, the hydrated object is validated against annotations and supplied validation constraints and groups.
handleRequest
Hydrate an object from the Request object. Property mapping is based on the submitted form property names matching the property names of the hydrated object. If $validate is true, the hydrated object is validated against annotations and supplied validation constraints and groups.
isValid
Is the hydrated object valid after processing the validation constraints. If no validation has occurred the method returns true;
getErrors
Return a Symfony\Component\Validator\ConstraintViolationListInterface list of any validation errors.
getJsonErrors
Return a JSON serialised version of getErrors().
Credits
- Ian Foulds as the creator of this package.
- Marco Pivetta (https://github.com/ocramius) for developing and maintaining the laminas-hydrator - https://github.com/laminas/laminas-hydrator.
License
This bundle is released under the MIT license. See the complete license in the bundle:
All versions of type-hint-hydrator with dependencies
doctrine/orm Version ^3.2
jms/serializer-bundle Version ^5.0
laminas/laminas-hydrator Version ^4.15
nette/utils Version 4.0
symfony/validator Version ^6.2||7.1
symfony/http-foundation Version ^6.2||7.1