Skip to content

[make:crud] fix conflict routes #922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Resources/skeleton/crud/controller/Controller.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ public function new(Request $request): Response
}

<?php if ($use_attributes) { ?>
#[Route('/{<?= $entity_identifier ?>}', name: '<?= $route_name ?>_show', methods: ['GET'])]
#[Route('/{<?= $entity_identifier ?>}', name: '<?= $route_name ?>_show', methods: ['GET'], requirements: ['<?= $entity_identifier ?>' => '\d+'])]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Howdy, thanks for the work on this. My biggest concern with this is if my entity has a string based id, e.g. uuid's, these routes will no longer work. For us to properly implement this dynamically, we would need to know the scalar type of the id for the entity.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I make a better regex to fix that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any news? @jrushlow

<?php } else { ?>
/**
* @Route("/{<?= $entity_identifier ?>}", name="<?= $route_name ?>_show", methods={"GET"})
* @Route("/{<?= $entity_identifier ?>}", name="<?= $route_name ?>_show", methods={"GET"}, requirements={"<?= $entity_identifier ?>"="\d+"})
*/
<?php } ?>
public function show(<?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
Expand All @@ -97,10 +97,10 @@ public function show(<?= $entity_class_name ?> $<?= $entity_var_singular ?>): Re
}

<?php if ($use_attributes) { ?>
#[Route('/{<?= $entity_identifier ?>}/edit', name: '<?= $route_name ?>_edit', methods: ['GET', 'POST'])]
#[Route('/{<?= $entity_identifier ?>}/edit', name: '<?= $route_name ?>_edit', methods: ['GET', 'POST'], requirements: ['<?= $entity_identifier ?>' => '\d+'])]
<?php } else { ?>
/**
* @Route("/{<?= $entity_identifier ?>}/edit", name="<?= $route_name ?>_edit", methods={"GET","POST"})
* @Route("/{<?= $entity_identifier ?>}/edit", name="<?= $route_name ?>_edit", methods={"GET","POST"}, requirements={"<?= $entity_identifier ?>"="\d+"})
*/
<?php } ?>
public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
Expand Down Expand Up @@ -128,10 +128,10 @@ public function edit(Request $request, <?= $entity_class_name ?> $<?= $entity_va
}

<?php if ($use_attributes) { ?>
#[Route('/{<?= $entity_identifier ?>}', name: '<?= $route_name ?>_delete', methods: ['POST'])]
#[Route('/{<?= $entity_identifier ?>}', name: '<?= $route_name ?>_delete', methods: ['POST']), requirements: ['<?= $entity_identifier ?>' => '\d+'])]
<?php } else { ?>
/**
* @Route("/{<?= $entity_identifier ?>}", name="<?= $route_name ?>_delete", methods={"POST"})
* @Route("/{<?= $entity_identifier ?>}", name="<?= $route_name ?>_delete", methods={"POST"}, requirements={"<?= $entity_identifier ?>"="\d+"})
*/
<?php } ?>
public function delete(Request $request, <?= $entity_class_name ?> $<?= $entity_var_singular ?>): Response
Expand Down