douyuefu1372
2019-06-12 12:54
浏览 71
已采纳

在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.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • doujumiao5024 2019-06-12 13:00
    最佳回答

    $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

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题