mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Api point for docgen templates
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user