Skip to content

Commit fe57e5a

Browse files
committed
Merge branch '2.5'
* 2.5: fix typos [HttpKernel] add use statement for phpdoc fixed DateComparator if file does not exist Disabled the PHPUnit self-update on Travis fix mustRun() in sigchild environments [ClassLoader] simplified phpdoc [ClassLoader] Add a __call() method to XcacheClassLoader fix some minor typos in tests [Yaml] fixed mapping keys containing a quoted # Added fixture to test parsing of hash keys ending with a space and # [Validator] Pass strict argument into the strict email validator [Filesystem Component] mkdir race condition fix #11626 [Validator] reverted permissions change on translation files Fixed Factory services not within the ServiceReferenceGraph. [CssSelector] Fix URL to SimonSapin/cssselect repo [Validator] Fixed wrong translation keys/messages for Collection constraint. The error messages for a missing field and an unexpected field did not match the Contraint class Remove hard dependency of RequestContext in AssetsExtension added useful reminder about form.vars.errors into UPGRADE-2.5 notes [YAML] resolve variables in inlined YAML Disallow abstract definitions from doctrine event listener registration Conflicts: src/Symfony/Component/Yaml/Inline.php src/Symfony/Component/Yaml/Parser.php src/Symfony/Component/Yaml/Tests/InlineTest.php
2 parents 6c09054 + a1b0775 commit fe57e5a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Extension/AssetsExtension.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AssetsExtension extends \Twig_Extension
2424
private $container;
2525
private $context;
2626

27-
public function __construct(ContainerInterface $container, RequestContext $requestContext)
27+
public function __construct(ContainerInterface $container, RequestContext $requestContext = null)
2828
{
2929
$this->container = $container;
3030
$this->context = $requestContext;
@@ -94,13 +94,18 @@ public function getName()
9494
* @param string $url The URL that has to be absolute
9595
*
9696
* @return string The absolute URL
97+
* @throws \RuntimeException
9798
*/
9899
private function ensureUrlIsAbsolute($url)
99100
{
100101
if (false !== strpos($url, '://') || 0 === strpos($url, '//')) {
101102
return $url;
102103
}
103104

105+
if (!$this->context) {
106+
throw new \RuntimeException('To generate an absolute URL for an asset, the Symfony Routing component is required.');
107+
}
108+
104109
if ('' === $host = $this->context->getHost()) {
105110
return $url;
106111
}

Resources/config/twig.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
<service id="twig.extension.assets" class="%twig.extension.assets.class%" public="false">
6767
<tag name="twig.extension" />
6868
<argument type="service" id="service_container" />
69-
<argument type="service" id="router.request_context" />
69+
<argument type="service" id="router.request_context" on-invalid="null" />
7070
</service>
7171

7272
<service id="twig.extension.actions" class="%twig.extension.actions.class%" public="false">

0 commit comments

Comments
 (0)