2017 © Pedro Peláez
 

symfony-bundle extra-param-converter-bundle

Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data

image

alxishin/extra-param-converter-bundle

Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data

  • Monday, May 14, 2018
  • by alxishin
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 4 Versions
  • 60 % Grown

The README.md

BuExtraParamConverterBundle

Todo: update the read me with our additions, (*1)

BuExtraParamConverterBundle extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data to entities, decode json data and strip tags from data., (*2)

Requires SensioFrameworkExtraBundle., (*3)

Build Status, (*4)

Installation

Add bundle with composer:, (*5)

composer require bu/extra-param-converter-bundle dev-master, (*6)

Register bundle in AppKernel.php: ``` php <?php // app/AppKernel.php, (*7)

public function registerBundles() { $bundles = array( // ... new Bu\ExtraParamConverterBundle\BuExtraParamConverterBundle(), ); }, (*8)


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" ``` php public function detailsAction(User $user) { ... }

where 123 is user id. It will throw NotFoundHttpException if can't find User by this id., (*9)

PostConverter ``` php use Bu\ExtraParamConverterBundle\Configuration\ExtraParamConverter;, (*10)

/**
 * @ExtraParamConverter("data", jsonData=true, stripTags=true, namespace="App", entities={"groups"={"class"="Group"}, "role"={"class"="Role"}})
 */
public function saveUserAction(array $data)
{
    // $data['groups'] ...
}
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:

Doctrine Configuration

doctrine: orm: mappings: ApplicationMySuperBundle: alias: My ``` This will allow you to use short namespace "My" instead of long autogenerated "ApplicationMySuperBundle"., (*11)

License

This bundle is under the MIT license., (*12)

The Versions

14/05 2018

dev-master

9999999-dev http://github.com/Fludimir/ExtraParamConverterBundle

Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data

  Sources   Download

MIT

The Requires

 

by Avatar Fludimir
by Irina Naydyonova

bundle doctrine annotation param-converter

14/05 2018

1.0.2

1.0.2.0 http://github.com/Fludimir/ExtraParamConverterBundle

Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data

  Sources   Download

MIT

The Requires

 

by Avatar Fludimir
by Irina Naydyonova

bundle doctrine annotation param-converter

17/10 2014

1.0.1

1.0.1.0 http://github.com/Fludimir/ExtraParamConverterBundle

Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data

  Sources   Download

MIT

The Requires

 

by Avatar Fludimir
by Irina Naydyonova

bundle doctrine annotation param-converter

24/06 2013

1.0.0

1.0.0.0 http://github.com/Fludimir/ExtraParamConverterBundle

Symfony2 bundle that extends Sensio ParamConverter functionality, allowing to convert simple GET and complex POST data

  Sources   Download

MIT

The Requires

 

by Avatar Fludimir
by Irina Naydyonova

bundle doctrine annotation param-converter