src/Controller/Api/TypeSoccerController.php line 34

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Api;
  3. use App\Entity\TypeSoccer;
  4. use App\Services\Api\TypeSoccerManager;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. class TypeSoccerController extends ApiController
  11. {
  12.   /** @var TypeSoccerManager $typeSoccerManager */
  13.   protected $typeSoccerManager;
  14.   /**
  15.    * @param TypeSoccerManager $typeSoccerManager
  16.    */
  17.   public function __construct(EntityManagerInterface $emParameterBagInterface $parameterBagTypeSoccerManager $typeSoccerManager)
  18.   {
  19.     parent::__construct($em$parameterBag);
  20.     $this->typeSoccerManager $typeSoccerManager;
  21.   }
  22.   /**
  23.    * @param Request $request
  24.    * @return JsonResponse
  25.    *
  26.    * @Route("/type_soccer/list", name="api_type_soccer_list", methods={"POST"})
  27.    */
  28.   public function listTypeSoccer()
  29.   {
  30.     $typeSoccers = [];
  31.     foreach ($this->em->getRepository(TypeSoccer::class)->findAll() as $key => $typeSoccer) {
  32.       $typeSoccers[] = $typeSoccer->__toArrayByTactics();
  33.     }
  34.     return $this->response($typeSoccers);
  35.   }
  36. }