mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-11-09 21:58:28 +00:00
Correct injection of services
This commit is contained in:
@@ -28,6 +28,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||
use Symfony\Contracts\Service\Attribute\Required;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
abstract class AbstractCRUDController extends AbstractController
|
||||
@@ -39,10 +40,23 @@ abstract class AbstractCRUDController extends AbstractController
|
||||
*/
|
||||
protected array $crudConfig = [];
|
||||
|
||||
public function __construct(protected readonly SerializerInterface $serializer, protected readonly ManagerRegistry $managerRegistry)
|
||||
protected ManagerRegistry $managerRegistry;
|
||||
protected SerializerInterface $serializer;
|
||||
|
||||
#[Required]
|
||||
public function setSerializer(SerializerInterface $serializer): void
|
||||
{
|
||||
$this->serializer = $serializer;
|
||||
}
|
||||
|
||||
#[Required]
|
||||
public function setManagerRegistry(ManagerRegistry $managerRegistry): void
|
||||
{
|
||||
$this->managerRegistry = $managerRegistry;
|
||||
}
|
||||
|
||||
// public function __construct(protected readonly SerializerInterface $serializer, protected readonly ManagerRegistry $managerRegistry) {}
|
||||
|
||||
/**
|
||||
* get the role given from the config.
|
||||
*/
|
||||
|
||||
@@ -24,11 +24,6 @@ use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||
|
||||
class ApiController extends AbstractCRUDController
|
||||
{
|
||||
public function __construct(SerializerInterface $serializer, ManagerRegistry $managerRegistry)
|
||||
{
|
||||
parent::__construct($serializer, $managerRegistry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base method for handling api action.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user