This commit is contained in:
@@ -2,14 +2,35 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\ConfigVariable;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
use App\Repository\ConfigVariableRepository;
|
||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||
use OpenApi\Attributes as OA;
|
||||
|
||||
class ConfigVariableController extends AbstractController
|
||||
{
|
||||
#[Route('/api/config', name: 'app_config_variable')]
|
||||
/**
|
||||
* Get All config variables.
|
||||
*/
|
||||
#[Route('/api/config', name: 'app_config_allVariable', methods: ["GET"])]
|
||||
#[OA\Tag(name: "Config")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Returns all public config variables.',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "results",
|
||||
type: "array",
|
||||
items: new OA\Items(ref: new Model(type: ConfigVariable::class))
|
||||
)
|
||||
]
|
||||
)
|
||||
)]
|
||||
public function getAllVariables(ConfigVariableRepository $repo): Response
|
||||
{
|
||||
$varList = $repo->findAllVariables();
|
||||
@@ -17,7 +38,22 @@ class ConfigVariableController extends AbstractController
|
||||
return $this->json(['results' => $varList]);
|
||||
}
|
||||
|
||||
#[Route('/api/config/section', name: 'app_config_sections')]
|
||||
#[Route('/api/config/section', name: 'app_config_sections', methods: ["GET"])]
|
||||
#[OA\Tag(name: "Config")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Returns all public config sections.',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "results",
|
||||
type: "array",
|
||||
items: new OA\Items(type: "string")
|
||||
)
|
||||
]
|
||||
)
|
||||
)]
|
||||
public function getSections(ConfigVariableRepository $repo): Response
|
||||
{
|
||||
$sectionList = $repo->getAllSections();
|
||||
@@ -30,7 +66,28 @@ class ConfigVariableController extends AbstractController
|
||||
return $this->json(['results' => $returnList]);
|
||||
}
|
||||
|
||||
#[Route('/api/config/section/{section}', name: 'app_config_variableBySection')]
|
||||
#[Route('/api/config/section/{section}', name: 'app_config_variableBySection', methods: ["GET"])]
|
||||
#[OA\Tag(name: "Config")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Returns all public config variables for given section.',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
properties: [
|
||||
new OA\Property(
|
||||
property: "results",
|
||||
type: "array",
|
||||
items: new OA\Items(ref: new Model(type: ConfigVariable::class))
|
||||
)
|
||||
]
|
||||
)
|
||||
)]
|
||||
#[OA\Parameter(
|
||||
name: 'section',
|
||||
in: 'path',
|
||||
description: 'Config section.',
|
||||
schema: new OA\Schema(type: 'string')
|
||||
)]
|
||||
public function getVariablesBySection(ConfigVariableRepository $repo, string $section): Response
|
||||
{
|
||||
if(\is_null($section) || $section == '') {
|
||||
@@ -42,7 +99,22 @@ class ConfigVariableController extends AbstractController
|
||||
return $this->json(['results' => $varList]);
|
||||
}
|
||||
|
||||
#[Route('/api/config/var/{key}', name: 'app_config_variable')]
|
||||
#[Route('/api/config/var/{key}', name: 'app_config_variable', methods: ["GET"])]
|
||||
#[OA\Tag(name: "Config")]
|
||||
#[OA\Response(
|
||||
response: 200,
|
||||
description: 'Get config variable by key.',
|
||||
content: new OA\JsonContent(
|
||||
type: 'object',
|
||||
ref: new Model(type: ConfigVariable::class),
|
||||
)
|
||||
)]
|
||||
#[OA\Parameter(
|
||||
name: 'key',
|
||||
in: 'path',
|
||||
description: 'Variable key.',
|
||||
schema: new OA\Schema(type: 'string')
|
||||
)]
|
||||
public function getByKey(ConfigVariableRepository $repo, string $key): Response
|
||||
{
|
||||
$var = $repo->findVariableByKey($key);
|
||||
|
||||
Reference in New Issue
Block a user