Api point for docgen templates

This commit is contained in:
Marc Ducobu
2021-08-18 17:05:13 +02:00
parent 9a1f56a820
commit d8ca9cf082
10 changed files with 114 additions and 32 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace Chill\DocGeneratorBundle\Controller;
use Chill\DocGeneratorBundle\Repository\DocGeneratorTemplateRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
/**
* Class DocGeneratorTemplateController
*
* @package Chill\DocGeneratorBundle\Controller
*/
class DocGeneratorTemplateController extends AbstractController
{
/**
* @Route(
* "{_locale}/doc/gen/templates/for/{entityClassName}",
* name="chill_docgenerator_templates_for_entity_api"
* )
*/
public function listTemplateApiAction(
string $entityClassName, DocGeneratorTemplateRepository $templateRepository): Response
{
$entities = $templateRepository->findByEntity($entityClassName);
$ret = array();
foreach ($entities as $entity) {
$ret[] = array(
'id' => $entity->getId(),
'name' => $entity->getName(),
'description' => $entity->getDescription()
);
}
return new JsonResponse(["results" => $ret]);
}
}