<?php
namespace App\Controller\Api;
use App\Entity\Category;
use App\Entity\Material;
use App\Entity\Customer;
use App\Entity\Exercise;
use App\Entity\ExerciseCalendar;
use App\Entity\ExerciseTranslation;
use App\Entity\ExerciseUser;
use App\Services\Api\CategoryManager;
use App\Services\Api\ExerciseManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
class CategoryController extends ApiController
{
/** @var CategoryManager $categoryManager */
protected $categoryManager;
/**
* @param CategoryManager $categoryManager
*/
public function __construct(EntityManagerInterface $em, ParameterBagInterface $parameterBag, CategoryManager $categoryManager)
{
parent::__construct($em, $parameterBag);
$this->categoryManager = $categoryManager;
}
/**
* @param Request $request
* @return JsonResponse
*
* @Route("/category/list", name="api_category_list", methods={"POST"})
*/
public function listExercise(Request $request)
{
//get categories
$listCategories = $this->em->getRepository(Category::class)->findAll();
$categories = [];
foreach ($listCategories as $category) {
$categories[] = $category->__toArray();
}
return $this->response($categories);
}
}