コード例 #1
0
 /**
  * @Route("/api/v1/authors", name="api_authors")
  * @param Request $request
  *
  * @return JsonResponse
  */
 public function indexAction(Request $request)
 {
     $authorName = $request->query->get('fullNameStartsWith');
     if (strlen($authorName) < 3) {
         throw new BadRequestHttpException("At least three letters needed to fetch author list");
     }
     $authors = $this->repository->findWithNameStartingWith($authorName);
     return new JsonResponse($this->normalizer->normalize($authors, 'json', ['groups' => ['list']]));
 }