<?php
namespace App\Controller\Api;
use App\Entity\AppModule;
use App\Entity\Customer;
use App\Services\Api\SupportManager;
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;
class AppModuleController extends ApiController
{
/** @var SupportManager $supportManager */
protected $supportManager;
/**
* @param SupportManager $supportManager
*/
public function __construct(EntityManagerInterface $em, ParameterBagInterface $parameterBag, SupportManager $supportManager)
{
parent::__construct($em, $parameterBag);
$this->supportManager = $supportManager;
}
/**
* @param Request $request
* @return JsonResponse
*
* @Route("/app-module/list", name="api_app_module_list", methods={"POST"})
*/
public function listExercise(Request $request)
{
$request = $this->transformJsonBody($request);
$appModules = [];
$prefixFile = $this->getParameter("app.path.exercise_images");
$baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
/** @var Customer $customer */
$customer = $this->getUser();
$season = $customer->getSeasonActive();
if (!empty($season)) {
$appModulesGet = $this->em->getRepository(AppModule::class)->findAll();
/** @var AppModule $appModule */
foreach ($appModulesGet as $appModule) {
$appModules[] = $appModule->__toArray($baseurl . $prefixFile . "/");
}
}
return $this->response($appModules);
}
protected function getDataForAddFromRequest(Request $request)
{
$data = [
"versionApp" => $request->get('versionApp'),
"device" => $request->get('device'),
"app_module_id" => $request->get('app_module_id'),
"customer_id" => $request->get('customer_id'),
"description" => $request->get('description'),
];
return $data;
}
}