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

Conversation

Olyno
Copy link

@Olyno Olyno commented Jul 5, 2021

Hi 👋🏻

I come with a fix for the routes generated by the make:crud. Routes with the "id" parameter conflict with other routes created. And since by default an id is a number, it's best to specify its content with the requirements in my opinion.

@@ -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

@jrushlow jrushlow added the Status: Needs Work Additional work is needed label Aug 19, 2021
@jrushlow jrushlow added the Feature New Feature label May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New Feature Status: Needs Work Additional work is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants