Skip to content

Commit b09673e

Browse files
author
vagrant
committed
Fix unused webroot
1 parent a045a8d commit b09673e

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

Twig/InlineCssParser.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77
namespace RobertoTru\ToInlineStyleEmailBundle\Twig;
88

9-
use Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator;
10-
use Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser;
119
use Symfony\Component\Config\FileLocatorInterface;
1210
use Symfony\Component\Templating\TemplateNameParserInterface;
1311
use Twig_NodeInterface;
@@ -16,31 +14,35 @@
1614
class InlineCssParser extends \Twig_TokenParser
1715
{
1816
/**
19-
* @var \Symfony\Component\Templating\TemplateNameParserInterface
17+
* @var TemplateNameParserInterface
2018
*/
2119
private $templateNameParser;
20+
2221
/**
23-
* @var \Symfony\Bundle\FrameworkBundle\Templating\Loader\TemplateLocator
22+
* @var FileLocatorInterface
2423
*/
2524
private $locator;
25+
2626
/**
27-
* @var \Symfony\Bundle\FrameworkBundle\Templating\TemplateNameParser
27+
* @var string
2828
*/
29-
private $name_parser;
29+
protected $webRoot;
30+
3031
/**
3132
* @var bool
3233
*/
3334
private $debug;
3435

3536
/**
3637
* @param FileLocatorInterface $locator used to get css asset real path
38+
* @param TemplateNameParserInterface $templateNameParser
3739
* @param string $webRoot web root of the project
3840
* @param bool $debug in debug mode css is not inlined but read on each render
3941
*/
40-
public function __construct(FileLocatorInterface $locator, $name_parser, $webRoot, $debug = false)
42+
public function __construct(FileLocatorInterface $locator, TemplateNameParserInterface $templateNameParser, $webRoot, $debug = false)
4143
{
4244
$this->locator = $locator;
43-
$this->name_parser = $name_parser;
45+
$this->templateNameParser = $templateNameParser;
4446
$this->webRoot = $webRoot;
4547
$this->debug = $debug;
4648
}
@@ -88,10 +90,10 @@ public function decideEnd(Twig_Token $token)
8890
private function resolvePath($path)
8991
{
9092
try {
91-
return $this->locator->locate($this->name_parser->parse($path));
93+
return $this->locator->locate($this->templateNameParser->parse($path));
9294
} catch (\InvalidArgumentException $e) {
9395
//happens when path is not bundle relative
94-
return $path;
96+
return $this->webRoot.'/'.$path;
9597
}
9698
}
9799
}

0 commit comments

Comments
 (0)