Comments (12)
Well, it could ve just an additional commodity for the developer, so you don’t need to inject the router constantly, and instead have the URL available out of the box.
from ezplatform-site-api.
Yup, that pretty much looks the same :)
from ezplatform-site-api.
Throwback to $node.url_alias
:)
What's the usecase? How would you generate the links in regards to siteaccess name being in the URL? We'd need a special route to generate the link with Symfony Routing.
It could be done currently with path(ezpublish.rootLocation) ~ location.url_alias
, but that seems clunky at best.
from ezplatform-site-api.
It should be generated through the router, so siteacess should already be there and no need to take care of it manually. If we implement it through a method, it can be generated on demand.
from ezplatform-site-api.
What I meant was, what's the usecase for having the URL alias in the location object directly? You can just as well use location.id
with ez_urlalias
route to generate a correct link by using path
or url
Twig functions.
from ezplatform-site-api.
Okay, so then that's not the URL alias, it's an URI (and that's not just semantics). Also, do you get the relative or the absolute URI? Do you support query params or fragments?
Also, out of the curiosity: how often do you actually generate the URLs in PHP (as opposed to Twig) that you need to inject the URL generator/router constantly in your services?
from ezplatform-site-api.
Both relative and absolute, and query parameters as well. Fragments probably not needed, from my POV it would be simpler to just concatenate than to have another argument.
I'm currently thinking something like (simplified):
function getUrl(array $queryParams): Url
class Url
{
public $relative;
public $absolute;
public function __toString()
{
return $this->relative;
}
}
Then you could write from Twig:
{{ location.url }}
{{ location.url.absolute }}
{{ location.url(params) }}
Also, out of the curiosity: how often do you actually generate the URLs in PHP (as opposed to Twig) that you need to inject the URL generator/router constantly in your services?
Actually quite often, the last use-case was JSON endpoint for a React app.
from ezplatform-site-api.
Actually quite often, the last use-case was JSON endpoint for a React app.
Okay, fair enough, for PHP it can be useful. As for Twig, how is this, which is already possible:
{{ path(location) }}
{{ url(location) }}
{{ url(location, params) }}
different from your example in terms of simplicity?
I'd rather prefer using path
and url
functions, since it's closer to the Symfony way of using the router.
from ezplatform-site-api.
We've had requests for this too. Often when dealing with locations (using APIs in PHP or over REST) people have a need for the url alias as well, or techanlly being able to get the final URI (more) easily. But as comments above says, it easily gets a bit complicated in terms of params and absolute vs relative. Unsure if this has been on @bdunogier's radar yet and/or if he has some thoughts about it :)
from ezplatform-site-api.
We're ATM quite busy with v3 release, but I plan to look into this again once that is finished.
from ezplatform-site-api.
@iherak do you still need this? :))
from ezplatform-site-api.
Yup, I still see a use for this. As @pspanja and @hknezevic mentioned, mostly valuable for usage through PHP, and that was the original intent of this issue :)
from ezplatform-site-api.
Related Issues (11)
- Mapping a field takes the wrong ID HOT 1
- Anonymous users do not have access to content.owner property HOT 1
- Inconsistent results HOT 13
- PagerFanta adapters and facets HOT 2
- How about a `findSingle` method on the findService to mimic `searchService` HOT 2
- No view template found for custom viewtype in latest ez platform version HOT 6
- Release version 3 HOT 1
- MatcherFactory Broken with ezplatform v3 HOT 2
- Problem on controller content preview override HOT 1
- Make bundle compatible with sensio/framework-extra-bundle ^6.0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ezplatform-site-api.