Use [#MapEntity()] attribute to inject entity into method + for now set controller_resolver.auto_mapping to true

This commit is contained in:
2025-05-28 14:58:59 +02:00
parent f282ffbfd4
commit 8ec18a6fb8
24 changed files with 120 additions and 117 deletions

View File

@@ -17,14 +17,16 @@ use Chill\BudgetBundle\Repository\ResourceRepository;
use Chill\BudgetBundle\Security\Authorization\BudgetElementVoter;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
class ElementController extends AbstractController
{
public function __construct(private readonly CalculatorManager $calculator, private readonly ResourceRepository $resourceRepository, private readonly ChargeRepository $chargeRepository) {}
#[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/elements/by-person/{id}', name: 'chill_budget_elements_index')]
public function indexAction(Person $person): \Symfony\Component\HttpFoundation\Response
#[Route(path: '{_locale}/budget/elements/by-person/{id}', name: 'chill_budget_elements_index')]
public function indexAction(#[MapEntity(id: 'id')] Person $person): \Symfony\Component\HttpFoundation\Response
{
$this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $person);
@@ -45,8 +47,8 @@ class ElementController extends AbstractController
]);
}
#[\Symfony\Component\Routing\Annotation\Route(path: '{_locale}/budget/elements/by-household/{id}', name: 'chill_budget_elements_household_index')]
public function indexHouseholdAction(Household $household): \Symfony\Component\HttpFoundation\Response
#[Route(path: '{_locale}/budget/elements/by-household/{id}', name: 'chill_budget_elements_household_index')]
public function indexHouseholdAction(#[MapEntity(id: 'id')] Household $household): \Symfony\Component\HttpFoundation\Response
{
$this->denyAccessUnlessGranted(BudgetElementVoter::SEE, $household);