Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
inoryy wants to merge5 commits intosymfony:masterfrominoryy:asset-url

Conversation

inoryy
Copy link
Contributor

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?no
Fixed tickets#5322
LicenseMIT
Doc PR-

This adds support forasset_url helper function, which returns asset absolute url, matching schema, host & port with server one.

Relies onRequestContext class, so if request is made from CLI thenrouter.request_context.* parameters are needed.

I've also added package alias calledabsolute_url, so a developer can use it insideasset function.
I think it's useful whenassets_base_urls parameter is used on production and simple absolute url is needed on dev.
Then a twig variable can be used, defined to beabsolute_url on dev ornull on prod.

<argument /> <!-- version format -->
</service>

<service id="absolute_url" alias="templating.asset.absolute_url_package" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A service namedabsolute_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

Copy link
ContributorAuthor

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 callingasset().
Do you think I should get rid of the alias completely or change to something else?

Copy link
Member

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 callingasset() is not a service id

Copy link
ContributorAuthor

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!

@fabpot
Copy link
Member

What about doing something simpler: adding a third option to theasset function for absolute URLs (which would basically do{{ app.request.getBaseUri ~ asset(...) }}) -- that's a viable option now that Twig support named arguments:asset('foo.png', absolute=true).

@qpautrat
Copy link

Hello everyone,

Any updates on this subject?@fabpot
I think it's really usefull.

Thanks.

@fabpot
Copy link
Member

Closing in favor of#10451

@fabpotfabpot closed thisMar 14, 2014
fabpot added a commit that referenced this pull requestMar 15, 2014
…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#3683This is another approach of#7722 - [x] Add unit tests - [x] Update docCommits-------76b8851 [TwigBundle] Add possibility to generate absolute assets urls
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

6 participants
@inoryy@fabpot@qpautrat@webmozart@cordoval@stof

[8]ページ先頭

©2009-2025 Movatter.jp