Inject managerRegistry and serializerInterface directly into controllers

This commit is contained in:
2025-05-28 12:04:27 +02:00
parent c8f1e67fc7
commit ab15ec8a4c
7 changed files with 70 additions and 25 deletions

View File

@@ -30,6 +30,7 @@ use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Doctrine\Persistence\ManagerRegistry;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
@@ -39,6 +40,7 @@ use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Serializer\Exception\RuntimeException;
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
use Symfony\Component\Serializer\SerializerInterface;
use Symfony\Component\Validator\ConstraintViolationList;
use Symfony\Component\Validator\ConstraintViolationListInterface;
use Symfony\Component\Validator\Validator\ValidatorInterface;
@@ -46,7 +48,18 @@ use Symfony\Component\Workflow\Registry;
final class AccompanyingCourseApiController extends ApiController
{
public function __construct(private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository, private readonly EventDispatcherInterface $eventDispatcher, private readonly ReferralsSuggestionInterface $referralAvailable, private readonly Registry $registry, private readonly ValidatorInterface $validator, private readonly \Doctrine\Persistence\ManagerRegistry $managerRegistry, private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository) {}
public function __construct(
private readonly AccompanyingPeriodRepository $accompanyingPeriodRepository,
private readonly EventDispatcherInterface $eventDispatcher,
private readonly ReferralsSuggestionInterface $referralAvailable,
private readonly Registry $registry,
private readonly ValidatorInterface $validator,
private readonly AccompanyingPeriodWorkRepository $accompanyingPeriodWorkRepository,
ManagerRegistry $managerRegistry,
SerializerInterface $serializer,
) {
parent::__construct($serializer, $managerRegistry);
}
public function commentApi($id, Request $request, string $_format): Response
{