-
Notifications
You must be signed in to change notification settings - Fork 18
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
[Routing] Data Object Routes #175
base: master
Are you sure you want to change the base?
[Routing] Data Object Routes #175
Conversation
All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
@solverat Got any feedback on this for me? :) |
@aarongerig Finaly i have some time to test it! First things first: Thanks for your efforts! 💪 |
@@ -25,13 +26,15 @@ abstract class BaseRouteItem | |||
protected ParameterBag $routeParameters; | |||
protected ParameterBag $routeAttributes; | |||
protected ParameterBag $routeContext; | |||
protected ?UrlSlug $urlSlug = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not add new properties to the route item which are very specific!
why not using the route context bag?
$routeItem->getRouteContextBag()->set('urlSlug', $urlSlug);
public function getUrlSlug(): ?UrlSlug | ||
{ | ||
return $this->urlSlug; | ||
} | ||
|
||
public function setUrlSlug(?UrlSlug $urlSlug): void | ||
{ | ||
$this->urlSlug = $urlSlug; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this, use route context bag?
|
||
public function getUrlSlug(): ?UrlSlug; | ||
|
||
public function setUrlSlug(?UrlSlug $urlSlug): void; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this, use route context bag?
? $routeItem->getRouteParameters() | ||
: $routeItem->getRouteAttributes(); | ||
$object = $routeItem->getEntity(); | ||
$urlSlug = $routeItem->getUrlSlug(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use route context bag the fetch the slug?
if ($routeItem->getType() === RouteItemInterface::DATA_OBJECT_ROUTE) { | ||
$alternateRouteItem->setRouteName($routeItem->getRouteName()); | ||
$alternateRouteItem->setEntity($routeItem->getEntity()); | ||
$alternateRouteItem->setUrlSlug($routeItem->getUrlSlug()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use route context bag the fetch the slug?
@@ -66,7 +73,8 @@ public function reverseTransformToArray(mixed $transformedRouteItem, array $cont | |||
'routeName' => $transformedRouteItem->getRouteName(), | |||
'routeParameters' => $transformedRouteItem->getRouteParameters(), | |||
'routeAttributes' => $transformedRouteItem->getRouteAttributes(), | |||
'context' => $transformedRouteItem->getRouteContext() | |||
'context' => $transformedRouteItem->getRouteContext(), | |||
'urlSlug' => $transformedRouteItem->getUrlSlug(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it, urlSlug would be available in context?
} elseif (str_starts_with($currentRouteName, 'data_object_')) { | ||
$routeItem = $this->routeItemFactory->create(RouteItemInterface::DATA_OBJECT_ROUTE, true); | ||
$routeItem->setEntity($baseRequest->attributes->get('object')); | ||
$routeItem->setUrlSlug($baseRequest->attributes->get('urlSlug')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use route context bag the set the slug?
'type' => RouteItemInterface::DATA_OBJECT_ROUTE, | ||
]); | ||
|
||
if ($routeItem->getEntity() === null || $routeItem->getUrlSlug() === null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use route context bag the fetch the slug?
@aarongerig, todo:
|
This PR adds data object routes (Pimcore UrlSlugs) to the toolchain. It automatically generates alternate routes without the user's need to intervene.
@solverat I've opened the PR as draft, as I'm not quite sure if that's everything that needs to be done in order to cover the complete functionality the other route types already have. I'm glad if you could review and provide some feedback! I'll add documentation after the coding has been done... 😉