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

[Example] Assign route to custom entity #87

Draft
wants to merge 1 commit into
base: example/custom-entity
Choose a base branch
from

Conversation

niklasnatter
Copy link
Contributor

@niklasnatter niklasnatter commented Nov 27, 2020

What's in this PR?

This PR demonstrates how to add a route to a custom entity using the route content type and the RouteBundle. This PR builds upon #84.

Screenshot 2020-11-30 at 16 31 54

To apply the changes, the schema of the database needs to be updated by executing bin/console doctrine:schema:update --force.

@niklasnatter niklasnatter changed the base branch from master to example/custom-entity November 27, 2020 15:56
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch 2 times, most recently from 1abeb02 to f72cc3c Compare November 27, 2020 15:57
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch 3 times, most recently from db5c6f4 to 15ca3f0 Compare November 27, 2020 16:10
@niklasnatter niklasnatter changed the title WIP: Assign route to custom entity [Example] Assign route to custom entity Nov 30, 2020
@niklasnatter niklasnatter marked this pull request as draft November 30, 2020 15:40
@niklasnatter niklasnatter added the Example Example implementations label Nov 30, 2020
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 15ca3f0 to 16e059c Compare November 30, 2020 15:59
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 16e059c to 935c1f1 Compare November 30, 2020 16:01
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch 2 times, most recently from ed2768e to 113d9b0 Compare December 18, 2020 11:02
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from cd4fe57 to 3a052f7 Compare January 25, 2021 09:06
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch 2 times, most recently from 32d4cf3 to a62a4d3 Compare January 25, 2021 10:27
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 3a052f7 to 3ccf457 Compare January 29, 2021 14:37
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch 2 times, most recently from d6685c3 to 2c95306 Compare January 29, 2021 14:41
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 3ccf457 to 737467e Compare February 3, 2021 09:45
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 2c95306 to 643df83 Compare February 3, 2021 09:47
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 737467e to 2f49214 Compare February 3, 2021 10:18
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 643df83 to 6ef010e Compare February 3, 2021 10:18
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 6ef010e to cdb9426 Compare February 16, 2021 14:36
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from cdb9426 to d8f6fef Compare February 16, 2021 14:39
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from d8f6fef to 7066b2c Compare February 26, 2021 10:32
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 69b1e17 to 46a3a42 Compare April 26, 2021 11:46
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 7066b2c to b0bf44b Compare April 26, 2021 11:48
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 46a3a42 to 66a3d03 Compare May 12, 2021 15:30
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch 2 times, most recently from 491f2cd to 6734f2a Compare May 12, 2021 15:36
@niklasnatter niklasnatter force-pushed the example/custom-entity branch from 66a3d03 to 18cd7be Compare June 20, 2022 17:42
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 6734f2a to 5ae3bb3 Compare June 20, 2022 17:57
@niklasnatter niklasnatter force-pushed the example/custom-entity-route branch from 5ae3bb3 to 6f021c3 Compare June 20, 2022 20:58
protected function updateRoutesForEntity(Event $entity): void
{
// create route for all locales of the application because event entity is not localized
foreach ($this->webspaceManager->getAllLocales() as $locale) {

Choose a reason for hiding this comment

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

What's the reason of going through all locales, when updating a route for specific locale? This usually would throw an error with NULL for the rest of the locales that are not currently edited/created

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As stated in the comment in the previous line, the event entity of the example is not localized. If your entity is localized, you want to update only the route of the current locale 🙂

@joelbeckmann
Copy link

Thank you for this Example!
I have encountered one problem for which I have not found a solution yet: When you are in the event editor and click on the button that shows you the URL history, I only get shown the history for the locale that is currently selected in the webspace. I think that behaviour can lead to some confusion for the end user. Does someone know if there is a way to show the history for all locales in the route editor?

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

Successfully merging this pull request may close these issues.

3 participants