sanjiisan

Untitled

May 26th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. /**
  2.      * @Route("/getTests", name="get_tests")
  3.      */
  4.     public function getTestsAction()
  5.     {
  6.         $tests = $this->getDoctrine()->getRepository('AppBundle:Test')->findAll();
  7.  
  8.         $result = [];
  9.  
  10.         foreach ($tests as $test) {
  11.             $result[] = [
  12.                 'name' => $test->getName(),
  13.                 'id' => $test->getId(),
  14.                 'price' => $test->getPrice(),
  15.             ];
  16.         }
  17.  
  18.         return new JsonResponse($result);
  19.     }
Add Comment
Please, Sign In to add comment