-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[WIP][2.3][FrameworkBundle][Templating] Generate assets with absolute url #7722
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
Conversation
<argument /> <!-- version format --> | ||
</service> | ||
|
||
<service id="absolute_url" alias="templating.asset.absolute_url_package" /> |
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.
A service named absolute_url
is a bad idea IMO. It does not descibe at all what the service is about.
thus, making the alias target the abstract service looks weird to me
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.
Idea was to add a simple name that developers can reference when calling asset()
.
Do you think I should get rid of the alias completely or change to something else?
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.
What you pass as argument when calling asset()
is not a service id
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.
You're right, misunderstood the setup. Thanks!
What about doing something simpler: adding a third option to the |
Hello everyone, Any updates on this subject? @fabpot Thanks. |
Closing in favor of #10451 |
…ts urls (romainneutron) This PR was merged into the 2.5-dev branch. Discussion ---------- [TwigBundle] Add possibility to generate absolute assets urls | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT | Doc PR | symfony/symfony-docs#3683 This is another approach of #7722 - [x] Add unit tests - [x] Update doc Commits ------- 76b8851 [TwigBundle] Add possibility to generate absolute assets urls
This adds support for
asset_url
helper function, which returns asset absolute url, matching schema, host & port with server one.Relies on
RequestContext
class, so if request is made from CLI thenrouter.request_context.*
parameters are needed.I've also added package alias called
absolute_url
, so a developer can use it insideasset
function.I think it's useful when
assets_base_urls
parameter is used on production and simple absolute url is needed on dev.Then a twig variable can be used, defined to be
absolute_url
on dev ornull
on prod.