Skip to content
This repository was archived by the owner on Oct 15, 2025. It is now read-only.

Commit 7ba375c

Browse files
committed
refactor: Migrate from deprecated auto-mapping
https://symfony.com/blog/new-in-symfony-7-1-mapped-route-parameters
1 parent 7e05ee8 commit 7ba375c

File tree

8 files changed

+14
-14
lines changed

8 files changed

+14
-14
lines changed

config/packages/doctrine.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
$ormConfig
5151
->controllerResolver()
52-
->autoMapping(true);
52+
->autoMapping(false);
5353

5454
$entityManager->dql()
5555
->datetimeFunction('date', SimpleFunction::class)

src/Controller/Admin/EmailDeliveryEventCrudController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function configureFilters(Filters $filters): Filters
4343
public function configureActions(Actions $actions): Actions
4444
{
4545
$previewAction = Action::new('preview', 'Preview', 'fa fa-eye')
46-
->linkToUrl(fn (EmailDeliveryEvent $entity) => $this->generateUrl(
46+
->linkToUrl(fn (EmailDeliveryEvent $event) => $this->generateUrl(
4747
'app_email_preview',
48-
['id' => $entity->getId()]
48+
['event' => $event->getId()]
4949
));
5050

5151
return $actions

src/Controller/ChallengeController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
class ChallengeController extends AbstractController
1818
{
19-
#[Route('/challenge/{id}', name: 'app_challenge')]
19+
#[Route('/challenge/{question}', name: 'app_challenge')]
2020
public function index(
2121
#[CurrentUser] User $user,
2222
Question $question,
@@ -27,7 +27,7 @@ public function index(
2727
]);
2828
}
2929

30-
#[Route('/challenge/{id}/solution-video', name: 'app_challenge_solution_video', methods: ['GET'])]
30+
#[Route('/challenge/{question}/solution-video', name: 'app_challenge_solution_video', methods: ['GET'])]
3131
public function solution_video(
3232
Question $question,
3333
EntityManagerInterface $entityManager,

src/Controller/EmailController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@
1313

1414
class EmailController extends AbstractController
1515
{
16-
#[Route('/email/{id}', name: 'app_email_preview')]
17-
public function details(#[CurrentUser] User $user, EmailDeliveryEvent $emailDeliveryEvent): Response
16+
#[Route('/email/{event}', name: 'app_email_preview')]
17+
public function details(#[CurrentUser] User $user, EmailDeliveryEvent $event): Response
1818
{
1919
// if this email is not owned by the current user and the user is not an admin,
2020
// we deny the access.
21-
if ($emailDeliveryEvent->getToUser() !== $user && !$this->isGranted('ROLE_ADMIN')) {
21+
if ($event->getToUser() !== $user && !$this->isGranted('ROLE_ADMIN')) {
2222
throw $this->createAccessDeniedException('You are not authorized to access this email.');
2323
}
2424

2525
return $this->render('email/preview.html.twig', [
26-
'emailDeliveryEvent' => $emailDeliveryEvent,
26+
'emailDeliveryEvent' => $event,
2727
]);
2828
}
2929
}

templates/comments/index.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
{% for comment in comments %}
1414
<li class="app-comments__item">
1515
<p class="app-comments__item__commented_at text-muted mb-2 fw-bold">#{{ comment.id }}・{{ comment.createdAt|date('Y-m-d H:i:s') }}・<i class="bi bi-hand-thumbs-up" aria-label="按讚數"></i> {{ comment.commentLikeEvents|length }}</p>
16-
<h5 class="app-comments__item__question text-body-tertiary">在<a class="text-body text-decoration-none" href="{{ path('app_challenge', {id: comment.question.id}) }}">第 {{ comment.question.id }} 題({{ comment.question.title }})</a>留言了</h5>
16+
<h5 class="app-comments__item__question text-body-tertiary">在<a class="text-body text-decoration-none" href="{{ path('app_challenge', {question: comment.question.id}) }}">第 {{ comment.question.id }} 題({{ comment.question.title }})</a>留言了</h5>
1717
<p class="app-comments__item__content">{{ comment.content|striptags }}</p>
1818
</li>
1919
{% endfor %}

templates/components/Challenge/Header.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<a
2828
class="btn btn-secondary {{ not previousPage ? 'disabled' : '' }}"
2929
role="button"
30-
href="{{ previousPage ? path('app_challenge', {id: previousPage}) : '#' }}"
30+
href="{{ previousPage ? path('app_challenge', {question: previousPage}) : '#' }}"
3131
aria-label="上一題"
3232
>
3333
<i class="bi bi-arrow-left"></i>
@@ -36,7 +36,7 @@
3636
<a
3737
class="btn btn-secondary {{ not nextPage ? 'disabled' : '' }}"
3838
role="button"
39-
href="{{ nextPage ? path('app_challenge', {id: nextPage}) : '#' }}"
39+
href="{{ nextPage ? path('app_challenge', {question: nextPage}) : '#' }}"
4040
aria-label="下一題"
4141
>
4242
<i class="bi bi-arrow-right"></i>

templates/components/Challenge/SolutionVideoModal.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'aria-label': '打開解答影片',
55
'aria-hidden': 'true',
66
'data-video-url': path('app_challenge_solution_video', {
7-
id: this.question.id,
7+
question: this.question.id,
88
csrf: csrf_token('challenge-solution'),
99
}),
1010
}|merge(stimulus_controller('challenge-solution-video-modal'))) }}>

templates/components/Questions/Card.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</div>
1111

1212
<div class="app-question-card__operations">
13-
<a role="button" class="btn btn-primary" href="{{ path('app_challenge', {id: question.id}) }}">進行測驗</a>
13+
<a role="button" class="btn btn-primary" href="{{ path('app_challenge', {question: question.id}) }}">進行測驗</a>
1414
{% set passRate = this.passRate %}
1515
<div class="app-question-card__pass-rate" data-pass-rate="{{ passRate.level }}">通過率 {{ passRate.passRate }}%</div>
1616
</div>

0 commit comments

Comments
 (0)