Add explicit controller definition requirement for APIs

Updated API creation to require an explicit controller definition. This change has been reflected in the ChillMainExtension and ChillPersonExtension files. Also, it has introduced a new exception, the InvalidCrudConfiguration, which will be thrown when a new API or CRUD is created without this explicit controller definition.
This commit is contained in:
2024-04-08 15:38:05 +02:00
parent 78a3dfd65e
commit 76fdd6d889
16 changed files with 253 additions and 29 deletions

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
class AccompanyingPeriodCommentApiController extends ApiController {}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
class AccompanyingPeriodResourceApiController extends ApiController {}

View File

@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Controller;
use Chill\MainBundle\CRUD\Controller\ApiController;
class RelationApiController extends ApiController {}

View File

@@ -17,11 +17,10 @@ use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Validator\Validator\ValidatorInterface;
class RelationshipApiController extends ApiController
{
public function __construct(private readonly ValidatorInterface $validator, private readonly RelationshipRepository $repository) {}
public function __construct(private readonly RelationshipRepository $repository) {}
/**
* @ParamConverter("person", options={"id": "person_id"})

View File

@@ -13,7 +13,10 @@ namespace Chill\PersonBundle\DependencyInjection;
use Chill\MainBundle\DependencyInjection\MissingBundleException;
use Chill\MainBundle\Security\Authorization\ChillExportVoter;
use Chill\PersonBundle\Controller\AccompanyingPeriodCommentApiController;
use Chill\PersonBundle\Controller\AccompanyingPeriodResourceApiController;
use Chill\PersonBundle\Controller\HouseholdCompositionTypeApiController;
use Chill\PersonBundle\Controller\RelationApiController;
use Chill\PersonBundle\Doctrine\DQL\AddressPart;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodCommentVoter;
@@ -537,6 +540,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
],
[
'class' => AccompanyingPeriod\Comment::class,
'controller' => AccompanyingPeriodCommentApiController::class,
'name' => 'accompanying_period_comment',
'base_path' => '/api/1.0/person/accompanying-period/comment',
'base_role' => 'ROLE_USER',
@@ -556,6 +560,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
],
[
'class' => AccompanyingPeriod\Resource::class,
'controller' => AccompanyingPeriodResourceApiController::class,
'name' => 'accompanying_period_resource',
'base_path' => '/api/1.0/person/accompanying-period/resource',
'base_role' => 'ROLE_USER',
@@ -874,6 +879,7 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
],
[
'class' => \Chill\PersonBundle\Entity\Relationships\Relation::class,
'controller' => RelationApiController::class,
'name' => 'relations',
'base_path' => '/api/1.0/relations/relation',
'base_role' => 'ROLE_USER',