Skip to content
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

Leverage AdminInterface::getIdParameter() and AdminInterface::getUrlSafeIdentifier() #7055

Merged
merged 2 commits into from
Apr 13, 2021

Conversation

franmomu
Copy link
Member

Subject

As suggested by @phansys for SonataPageBundle, this PR removes the hardcode id parameter in favor of AdminInterface::getIdParameter() method.

Also replaces the use of AdminInterface::id() when generating URLs by AdminInterface::getUrlSafeIdentifier().

I am targeting this branch, because these changes are BC.

Changelog

### Fixed
- Fixed using the hardcode `id` parameter instead of calling `AdminInterface::getIdParameter()` method.

@franmomu franmomu added the patch label Apr 13, 2021
@franmomu franmomu requested a review from phansys April 13, 2021 17:29
Removes the hardcode id parameter in favor of AdminInterface::getIdParameter() method.
And recommend in docs the use of AdminInterface::generateObjectUrl() method.
Instead of AdminInterface::id() when generating URLs.
@franmomu franmomu force-pushed the do_not_hardcode_id branch from 45f3b61 to cc9fd30 Compare April 13, 2021 17:32
{% elseif admin.hasAccess('show', object) and admin.hasRoute('show') %}
<a href="{{ admin.generateUrl('show', {'id' : object|sonata_urlsafeid(admin) }) }}">{{ meta.title|u.truncate(40) }}</a>
Copy link
Member

@VincentLanglet VincentLanglet Apr 13, 2021

Choose a reason for hiding this comment

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

If we cannot deprecate sonata_urlsafeid (#6963 (comment)),
Can we at least deprecate the param admin of the sonata_urlsafeid filter ?

(But the best would be to deprecate sonata_urlsafeid to promote passing the admin in the view and using generateObjectUrl... ; and if a bundle cannot do without it, it will implement his own extension)

@VincentLanglet VincentLanglet merged commit 627e79d into sonata-project:3.x Apr 13, 2021
{{ mosaic_content }}
</a>
{% elseif admin.hasAccess('show', object) and admin.hasRoute('show') %}
<a class="mosaic-inner-link"
href="{{ admin.generateUrl('show', {'id' : object|sonata_urlsafeid(admin) }) }}">
href="{{ admin.generateUrl('show', {(admin.idParameter) : object|sonata_urlsafeid(admin) }) }}">
Copy link
Member

Choose a reason for hiding this comment

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

this can be changed to not use the filter right?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep #7061

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants