-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathInlineCssExtension.php
More file actions
84 lines (73 loc) · 1.79 KB
/
InlineCssExtension.php
File metadata and controls
84 lines (73 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
* This file is part of ToInlineStyleEmailBundle.
*
* (c) Roberto Trunfio <roberto@trunfio.it>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace RobertoTru\ToInlineStyleEmailBundle\Twig;
use RobertoTru\ToInlineStyleEmailBundle\Converter\ToInlineStyleEmailConverter;
use Symfony\Component\Config\FileLocatorInterface;
use Twig\Extension\GlobalsInterface as TwigExtensionGlobalsInterface;
/**
* Responsible to construct the instance responsible to inject the inline csss.
*
* @package RobertoTru\ToInlineStyleEmailBundle\Twig
*/
class InlineCssExtension extends \Twig_Extension implements TwigExtensionGlobalsInterface
{
/**
* @var ToInlineStyleEmailConverter
*/
private $inlineCss;
/**
* @var string
*/
private $webRoot;
/**
* @var FileLocatorInterface
*/
private $locator;
/**
* @var bool
*/
private $debug;
public function __construct(
ToInlineStyleEmailConverter $inlineCss,
FileLocatorInterface $locator,
$webRoot,
$debug = false
) {
$this->inlineCss = $inlineCss;
$this->locator = $locator;
$this->webRoot = $webRoot;
$this->debug = $debug;
}
/**
* {@inheritDoc}
*/
public function getTokenParsers()
{
return array(new InlineCssParser($this->locator, $this->webRoot, $this->debug));
}
/**
* {@inheritDoc}
*/
public function getGlobals()
{
return array(
'inlinecss' => $this->inlineCss,
);
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'inlinecss';
}
}