-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[TwigBundle] Remove hard dependency of RequestContext in AssetsExtension #11749
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
@@ -101,6 +110,10 @@ private function ensureUrlIsAbsolute($url) | |||
return $url; | |||
} | |||
|
|||
if (!$this->context) { | |||
throw new \RuntimeException("To ensure a URL as absolute the Symfony Routing component is required."); |
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.
message should be single-quoted.
@@ -13,6 +13,7 @@ | |||
|
|||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | |||
use Symfony\Component\DependencyInjection\ContainerBuilder; | |||
use Symfony\Component\DependencyInjection\Reference; |
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.
should probably be removed.
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.
Absolutely, sorry for missing it. Done.
5f8c884
to
8e38cbd
Compare
@@ -101,6 +111,10 @@ private function ensureUrlIsAbsolute($url) | |||
return $url; | |||
} | |||
|
|||
if (!$this->context) { | |||
throw new \RuntimeException('To ensure a URL as absolute the Symfony Routing component is required.'); |
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.
This message looks weird to me. "To ensure a URL as absolute..." -> "To generate an absolut URL for an asset, ..."
👍 |
1 similar comment
👍 |
Thank you @pgodel. |
…ssetsExtension (pgodel) This PR was merged into the 2.5 branch. Discussion ---------- [TwigBundle] Remove hard dependency of RequestContext in AssetsExtension | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11466 | License | MIT | Doc PR | - #10451 introduced the requirement of RequestContext in AssetsExtension. This is only needed when generating absolute URLs for assets. When sending emails with Twig from the CLI, the router may not be present and most times is not required. This PR attempts to remove the hard dependency and set RequestContext if the router is present according to issue #11466. Commits ------- 5ad4d8a Remove hard dependency of RequestContext in AssetsExtension
#10451 introduced the requirement of RequestContext in AssetsExtension. This is only needed when generating absolute URLs for assets. When sending emails with Twig from the CLI, the router may not be present and most times is not required.
This PR attempts to remove the hard dependency and set RequestContext if the router is present according to issue #11466.