mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-10-01 02:49:42 +00:00
Correct injection of services
This commit is contained in:
@@ -27,10 +27,7 @@ class StoredObjectApiController extends ApiController
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Security $security,
|
private readonly Security $security,
|
||||||
private readonly EntityManagerInterface $entityManager,
|
private readonly EntityManagerInterface $entityManager,
|
||||||
SerializerInterface $serializer,
|
|
||||||
ManagerRegistry $managerRegistry,
|
|
||||||
) {
|
) {
|
||||||
parent::__construct($serializer, $managerRegistry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,6 +28,7 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
|||||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||||
use Symfony\Component\Serializer\SerializerInterface;
|
use Symfony\Component\Serializer\SerializerInterface;
|
||||||
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
use Symfony\Component\Validator\Validator\ValidatorInterface;
|
||||||
|
use Symfony\Contracts\Service\Attribute\Required;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
abstract class AbstractCRUDController extends AbstractController
|
abstract class AbstractCRUDController extends AbstractController
|
||||||
@@ -39,10 +40,23 @@ abstract class AbstractCRUDController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
protected array $crudConfig = [];
|
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.
|
* get the role given from the config.
|
||||||
*/
|
*/
|
||||||
|
@@ -24,11 +24,6 @@ use Symfony\Component\Validator\ConstraintViolationListInterface;
|
|||||||
|
|
||||||
class ApiController extends AbstractCRUDController
|
class ApiController extends AbstractCRUDController
|
||||||
{
|
{
|
||||||
public function __construct(SerializerInterface $serializer, ManagerRegistry $managerRegistry)
|
|
||||||
{
|
|
||||||
parent::__construct($serializer, $managerRegistry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base method for handling api action.
|
* Base method for handling api action.
|
||||||
*
|
*
|
||||||
|
@@ -23,13 +23,6 @@ use Symfony\Component\Serializer\SerializerInterface;
|
|||||||
|
|
||||||
class AddressApiController extends ApiController
|
class AddressApiController extends ApiController
|
||||||
{
|
{
|
||||||
public function __construct(
|
|
||||||
SerializerInterface $serializer,
|
|
||||||
ManagerRegistry $managerRegistry,
|
|
||||||
) {
|
|
||||||
parent::__construct($serializer, $managerRegistry);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duplicate an existing address.
|
* Duplicate an existing address.
|
||||||
*/
|
*/
|
||||||
|
@@ -55,10 +55,7 @@ final class AccompanyingCourseApiController extends ApiController
|
|||||||
private readonly Registry $registry,
|
private readonly Registry $registry,
|
||||||
private readonly ValidatorInterface $validator,
|
private readonly ValidatorInterface $validator,
|
||||||
private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
|
private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
|
||||||
ManagerRegistry $managerRegistry,
|
|
||||||
SerializerInterface $serializer,
|
|
||||||
) {
|
) {
|
||||||
parent::__construct($serializer, $managerRegistry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function commentApi($id, Request $request, string $_format): Response
|
public function commentApi($id, Request $request, string $_format): Response
|
||||||
|
@@ -37,10 +37,7 @@ class HouseholdApiController extends ApiController
|
|||||||
private readonly EventDispatcherInterface $eventDispatcher,
|
private readonly EventDispatcherInterface $eventDispatcher,
|
||||||
private readonly HouseholdRepository $householdRepository,
|
private readonly HouseholdRepository $householdRepository,
|
||||||
private readonly HouseholdACLAwareRepositoryInterface $householdACLAwareRepository,
|
private readonly HouseholdACLAwareRepositoryInterface $householdACLAwareRepository,
|
||||||
ManagerRegistry $managerRegistry,
|
|
||||||
SerializerInterface $serializer,
|
|
||||||
) {
|
) {
|
||||||
parent::__construct($serializer, $managerRegistry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -47,11 +47,8 @@ class HouseholdMemberController extends ApiController
|
|||||||
private readonly HouseholdRepository $householdRepository,
|
private readonly HouseholdRepository $householdRepository,
|
||||||
private readonly Security $security,
|
private readonly Security $security,
|
||||||
private readonly PositionRepository $positionRepository,
|
private readonly PositionRepository $positionRepository,
|
||||||
ManagerRegistry $managerRegistry,
|
|
||||||
SerializerInterface $serializer,
|
|
||||||
protected ParameterBagInterface $parameterBag,
|
protected ParameterBagInterface $parameterBag,
|
||||||
) {
|
) {
|
||||||
parent::__construct($serializer, $managerRegistry);
|
|
||||||
$this->household_fields_visibility = $parameterBag->get('chill_person.household_fields');
|
$this->household_fields_visibility = $parameterBag->get('chill_person.household_fields');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,7 +22,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
|
||||||
|
|
||||||
class PersonApiController extends ApiController
|
class PersonApiController extends ApiController
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user