Skip to content

Instantly share code, notes, and snippets.

@erop
Created April 27, 2021 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erop/8c7fc0f36836db1171152507aa7e52df to your computer and use it in GitHub Desktop.
Save erop/8c7fc0f36836db1171152507aa7e52df to your computer and use it in GitHub Desktop.
Controller for exposing document schemas
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Service\DocumentSchemaService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\Routing\Annotation\Route;
final class DocumentSchemaController extends AbstractController
{
private DocumentSchemaService $service;
public function __construct(DocumentSchemaService $service)
{
$this->service = $service;
}
/**
* @Route("/document-schemas", name="app_document_schemas", methods={"GET"})
*/
public function getDocumentSchemas(): JsonResponse
{
$schemas = ($this->service)();
return new JsonResponse($schemas);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment