コード例 #1
0
 /**
  * Core controller handler.
  *
  * @param FilterControllerEvent $event
  *
  * @throws \InvalidArgumentException
  */
 public function onKernelController(FilterControllerEvent $event)
 {
     $request = $event->getRequest();
     $controller = $event->getController();
     if (is_callable($controller) && method_exists($controller, '__invoke')) {
         $controller = [$controller, '__invoke'];
     }
     $this->scopeFetcher->setController($controller);
     $attributeName = $this->getAttributeName($controller);
     $request->attributes->set($attributeName, $this->scopeFetcher);
 }
コード例 #2
0
 /**
  * Returns movie comment
  *
  * @ApiDoc(
  *     views={"default", "movie-comment"},
  *     section="MovieComment API",
  *     statusCodes={
  *         200="Returned when successful",
  *         400="Returned when an error has occurred"
  *     },
  *     responseMap={
  *         200 = {"class": null, "options": {"data_schema": "movie_comment.schema.yml"}}
  *     }
  * )
  *
  * @Route("movie-comments/{movieComment}", name="api_movie_comment_get_movie_comment", requirements={
  *     "_scope":  "[\w,]+"
  * }, defaults={"_format": "json"}, methods={"GET"})
  *
  * @RestExtra\Scope(name="list", path="movie_comment/view.yml")
  *
  * @param MovieComment $movieComment
  * @param ScopeFetcherInterface $scopeFetcher
  * @param Request $request
  * @return View
  */
 public function getMovieCommentAction(MovieComment $movieComment, ScopeFetcherInterface $scopeFetcher, Request $request)
 {
     $datagridBuilder = $this->get('glavweb_datagrid.doctrine_datagrid_builder');
     $datagridBuilder->setEntityClassName(MovieComment::class)->setDataSchema('movie_comment.schema.yml', $scopeFetcher->getAvailable($request->get('_scope'), 'movie_comment/view.yml'))->addFilter('id', null, ['operator' => Filter::EQ]);
     $datagrid = $datagridBuilder->build(['id' => $movieComment->getId()]);
     return $this->view($datagrid->getItem());
 }