0

I have configured FOSRestBundle like following:

fos_rest:
  param_fetcher_listener: true
  body_listener: true
  format_listener: true
  view:
    view_response_listener: 'force'
  routing_loader:
    default_format: json
    include_format: false

In my class if extend like this

class PlayerController extends FOSRestController implements ClassResourceInterface

So i am able to build methods like

/**
 * Get all players.
 *
 * @return array
 *
 * @Rest\View
 */
public function cgetAction()
{
    $players = $this->getDoctrine()
      ->getRepository('bbbFrontendBundle:Player')
      ->findAll();

    return array('players' => $players);
}

which provides me a route get_players where i can reqeust all players through a GET request.

Now my question: I wanna provide a searchAction($searchterm, $limit) method which listens to GET and provide searchresults through elasticsearch by a given searchterm. The problem that im facing is, all custom methods are automatically associated with the PATCH method. And with PATCH method im not able to provide parameters and get a result like i want to. How can i achieve my method to listen to GET request??

1 Answer 1

1

You can define cget action with custom suffix. For example:

public function cgetSearchAction()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.