Add support using Route Entity for Entities with AutoIncrement Id #7859
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's in this PR?
We have some kind of a
Chicken & Egg
problem when try to use theRoute
entity with a Entity which using auto increment ids. As the Route entity requires theresourceId
but the Entity itself does not yet have agetId()
.In this pull request we are adding a new way to create a instance of
Route
without knowing the related resourceId at that time.This new method will generate the route with a resourceId
temp::<ulid::base58>
which later will be replaced in apostFlush
listener with the correct id of the entity. As discussed with @Prokyonn we decided to useulid::base58
to avoid confusen with uuid, so if something went wrong and they see in the database temp::ulid they not confuse it with a uuid which may exist as page or article.Why?
As the
Route
entity can be used also for entities which has a autoincremented ids which only exists afterflush
.Example Usage
If you have a entity with autoincrement id use the
createRouteWithTempId
to create your route and the bundle will automatically on postFlush call your callback method to get the correct id and set it to the route entity correctly:To Do