Skip to content

Commit 0142e1f

Browse files
seb-jeanjrushlow
andauthored
feature #1545 [make:crud] use getString() instead of get() for csrf token
Co-authored-by: Jesse Rushlow <[email protected]>
1 parent f8175a2 commit 0142e1f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Resources/skeleton/crud/controller/Controller.tpl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
7777
<?= $generator->generateRouteForControllerMethod(sprintf('/{%s}', $entity_identifier), sprintf('%s_delete', $route_name), ['POST']) ?>
7878
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>, EntityManagerInterface $entityManager): Response
7979
{
80-
if ($this->isCsrfTokenValid('delete'.$<?= $entity_var_singular ?>->get<?= ucfirst($entity_identifier) ?>(), $request->getPayload()->get('_token'))) {
80+
if ($this->isCsrfTokenValid('delete'.$<?= $entity_var_singular ?>->get<?= ucfirst($entity_identifier) ?>(), $request->getPayload()->getString('_token'))) {
8181
$entityManager->remove($<?= $entity_var_singular ?>);
8282
$entityManager->flush();
8383
}

tests/fixtures/make-crud/expected/WithCustomRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function edit(Request $request, SweetFood $sweetFood, EntityManagerInterf
7171
#[Route('/{id}', name: 'app_sweet_food_delete', methods: ['POST'])]
7272
public function delete(Request $request, SweetFood $sweetFood, EntityManagerInterface $entityManager): Response
7373
{
74-
if ($this->isCsrfTokenValid('delete'.$sweetFood->getId(), $request->getPayload()->get('_token'))) {
74+
if ($this->isCsrfTokenValid('delete'.$sweetFood->getId(), $request->getPayload()->getString('_token'))) {
7575
$entityManager->remove($sweetFood);
7676
$entityManager->flush();
7777
}

0 commit comments

Comments
 (0)