0

FOSRestBundle annotations are not working for me somehow.

use FOS\RestBundle\Controller\Annotations as Rest;

// ...

/**
* @Rest\RequestParam(name="email")
*/
public function someAction(Request $request) 
{ 
   // some code
}

Here's my config:

fos_rest:
    param_fetcher_listener: true
    body_listener: true
    format_listener: false
    routing_loader:
       default_format: json
    view:
        view_response_listener: 'force'
        formats:
            xml: false
            json : true
        default_engine: none
        templating_formats:
            html: true
    access_denied_listener:
        json: true
    allowed_methods_listener: true

Requests to this action ignores annotation and just executes method's code. It seems that listener that should resolve these annotations is not running. Any suggestions?

Roman Kliuchko
  • 499
  • 4
  • 20

1 Answers1

2

change param_fetcher_listener: true to param_fetcher_listener: force and move code to:

use FOS\RestBundle\Request\ParamFetcher

/**
 * @Rest\RequestParam(name="email")
 */
public function someAction(ParamFetcher $paramFetcher) {

   $email = $paramFetcher->get('email');
} 

Note: Request parameter must be passed as POST

M. Foti
  • 3,156
  • 2
  • 16
  • 14
  • I've tried it, but nothing was injected as $email: "requires that you provide a value for the "$email" argument". It seems that problem is deeper, may be in configuration. – Roman Kliuchko Sep 05 '14 at 12:42
  • 2
    it seems that "param_fetcher_listener: force" fixed problem. Thanks a lot. – Roman Kliuchko Sep 05 '14 at 12:51