Giter Site home page Giter Site logo

Comments (12)

hknezevic avatar hknezevic commented on May 26, 2024 2

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.

pspanja avatar pspanja commented on May 26, 2024 1

Yup, that pretty much looks the same :)

from ezplatform-site-api.

emodric avatar emodric commented on May 26, 2024

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.

pspanja avatar pspanja commented on May 26, 2024

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.

emodric avatar emodric commented on May 26, 2024

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.

emodric avatar emodric commented on May 26, 2024

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.

pspanja avatar pspanja commented on May 26, 2024

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.

emodric avatar emodric commented on May 26, 2024

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.

andrerom avatar andrerom commented on May 26, 2024

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.

pspanja avatar pspanja commented on May 26, 2024

We're ATM quite busy with v3 release, but I plan to look into this again once that is finished.

from ezplatform-site-api.

ilukac avatar ilukac commented on May 26, 2024

@iherak do you still need this? :))

from ezplatform-site-api.

iherak avatar iherak commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.