Download the PHP package bu/extra-param-converter-bundle without Composer
On this page you can find all versions of the php package bu/extra-param-converter-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bu/extra-param-converter-bundle
More information about bu/extra-param-converter-bundle
Files in bu/extra-param-converter-bundle
Package extra-param-converter-bundle
Short Description Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data
License MIT
Homepage http://github.com/Fludimir/ExtraParamConverterBundle
Informations about the package extra-param-converter-bundle
BuExtraParamConverterBundle
BuExtraParamConverterBundle extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data to entities, decode json data and strip tags from data.
Requires SensioFrameworkExtraBundle.
Installation
Add bundle with composer:
composer require bu/extra-param-converter-bundle dev-master
Register bundle in AppKernel.php:
Sensio ParamConverter should be enabled, ie parameter sensio_framework_extra.request.converters
in your app config should be set to true (set by default).
Usage
GetConverter
You don't need to write any annotations, following code will work with any GET request with user
parameter, like "/getUserDetails?user=123"
where 123 is user id. It will throw NotFoundHttpException if can't find User by this id.
PostConverter
In this example:
- raw post data will be json-decoded (jsonData=false by default for standard form submit)
- all string values will be filtered (stripTags=false by default)
- all "groups" will converted to "Group" entities, array [id1, id2, id3] - to array of "App:Group" entities
- all "role" will converted to "Role" entity, single value to single entity
- all is processed recursively to deepest level
- result will available in $data (confugired by first unnamed parameter in annotation)
- exceptions will be thrown in number of incorrect situations:
- invalid json data, invalid post data
- entities are defined without namespace (you can ommit them both if want only jsonDecode/stripTags)
- key defined for entity not found in data
- any entity not found by id
Recommented to set doctrine mapping alias for your bundle:
This will allow you to use short namespace "My" instead of long autogenerated "ApplicationMySuperBundle".
License
This bundle is under the MIT license.
All versions of extra-param-converter-bundle with dependencies
symfony/framework-bundle Version >=2.1,<2.4-dev
sensio/framework-extra-bundle Version 2.3.*
doctrine/orm Version ~2.2,>=2.2.3