在API中使用时$ request-> get('foo')会做什么?

在API中使用时$ request-> get('foo')会做什么?

问题描述:

Beginner question, ive search around the internet but it does not explain it very well. What does $request->get('foo') do when using in combination in API request.

  @Get("/event/{eventId}/eventAttendee")
      *
      * @View(serializerGroups={"Default"})
      * @ApiDoc(
      *  output= {
       *      "class" = "array<KCM\ApiBundle\Contract\EventAttendee>",
       *      "groups" = {"Default"}
       *  },
       *  requirements={
       *    {
       *      "name"="eventId",
       *      "dataType"="string",
       *      "requirement"="(\w|-)+",
       *      "description"="Event ID"
       *    },
       *    {
       *      "name"="filter",
       *      "dataType"="string",
       *      "requirement"="(\w|-)+",
       *      "description"="Value to search for within fields"
       *    }
       *  }
       * )
       *     

public function getEventAttendeesByFilterAction (Reqest $request, $eventID)

 $filter = $request->get('filter')

trying to find out what does $filter do when combined with this controller. I put the annotations above as well.

$request->get() retrieve the variable value given in either a GET or a POST request. In your case it retrieves the filter variable value.

You can read this documentation which talk about HTTP requests : https://symfony.com/doc/current/introduction/http_fundamentals.html