-
Notifications
You must be signed in to change notification settings - Fork 203
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
EZP-31499: Implemented ez_path/ez_url Twig functions #3000
Conversation
$routeName = $object->getRoute(); | ||
$parameters += $object->getParams(); | ||
} else { | ||
throw new InvalidArgumentException('$object', 'Unsupported class: ' . get_class($object)); |
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.
It would be nice if this would not throw, rather somehow allow using these methods in other packages like Netgen Tags, which also used path
and url
to generate links to tag objects.
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.
That would be useful extension point, we will think of it. For now in all cases which are not supported by eZ Platform I've added fallback to replacement proposed by symfony-cmf/routing
.
// cc @bdunogier
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.
Thanks, I think this will be enough for now. I will test once you merge this.
4076da9
to
f926d08
Compare
if ($name instanceof RouteReference) { | ||
$parameters += $name->getParams(); | ||
$name = $name->getRoute(); | ||
} |
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.
It doesn't work anymore. In theory we could provide support for syntax
$this->urlGenerator->generate('', [
RouteObjectInterface::ROUTE_OBJECT => $routeRef
])
but it will require to impl. \Symfony\Cmf\Component\Routing\ChainedRouterInterface
which seems to be overkill for me.
master
Implemented
ez_path
/ez_url
functions which allows to generating path/url in Twig templates from the objects of the following classes\eZ\Publish\API\Repository\Values\Content\Content
\eZ\Publish\API\Repository\Values\Content\ContentInfo
\eZ\Publish\API\Repository\Values\Content\Location
\eZ\Publish\Core\MVC\Symfony\Routing\RouteReference
It's replacement for build-in
path
/url
twig functions which no longer accept anything else thenstring
as first argument:Demo: https://gist.github.com/adamwojs/3056d518ac41b0d1e8a9937e4eece069
TODO:
$ composer fix-cs
).