Skip to content

Commit 0fcda0a

Browse files
author
David Cochrum
committed
Add Overridable Parameter Containing Path to Public Directory
- Adds `css_to_inline_email_twig_extension.public_dir` parameter containing path to public directory (default remains as `web` just outside kernel root) - Removes unused `use` statements - Adds twig as dev dependency
1 parent 95a454c commit 0fcda0a

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.idea
12
phpunit.xml
23
composer.lock
34
/vendor

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ $converter->setHTMLByView(
6969
);
7070
```
7171

72-
The preceding function must be used _in vece_ of function ```setHTML()```.
72+
The preceding function must be used _instead_ of ```setHTML()```.
7373

7474
To use the ```generateStyledHTML``` method just use it like:
7575

@@ -121,6 +121,10 @@ Dynamic variable is supported (Use absolute path with variable with asset or dir
121121

122122
Read the docs in the files for further details on the usage of the service.
123123

124+
Configuration
125+
=============
126+
The `css_to_inline_email_twig_extension.public_dir` parameter contains the path to the root directory accessible to the web. This path is assumed to be a `web` directory just outside the kernel root directory as recommended in Symfony 2-3 (`%kernel.root_dir%/../web`). With Symfony 4, the recommended path moved to a `public` directory just outside the kernel root directory (`%kernel.root_dir%/../public`). Override the parameter with the correct path for your implementation.
127+
124128
Contributing
125129
============
126130
**ToInlineStyleEmailBundle** is an open source project, under MIT license. Contributions are encouraged.

Resources/config/services.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<parameters>
88
<parameter key="css_to_inline_email_converter.class">RobertoTru\ToInlineStyleEmailBundle\Converter\ToInlineStyleEmailConverter</parameter>
99
<parameter key="css_to_inline_email_twig_extension.class">RobertoTru\ToInlineStyleEmailBundle\Twig\InlineCssExtension</parameter>
10+
<parameter key="css_to_inline_email_twig_extension.public_dir">%kernel.root_dir%/../web</parameter>
1011
</parameters>
1112

1213
<services>
@@ -16,7 +17,7 @@
1617
<service id="css_to_inline_email_twig_extension" class="%css_to_inline_email_twig_extension.class%">
1718
<argument type="service" id="css_to_inline_email_converter" />
1819
<argument type="service" id="file_locator" />
19-
<argument>%kernel.root_dir%</argument>
20+
<argument>%css_to_inline_email_twig_extension.public_dir%</argument>
2021
<argument>%kernel.debug%</argument>
2122
<tag name="twig.extension" />
2223
</service>

Twig/InlineCssExtension.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use RobertoTru\ToInlineStyleEmailBundle\Converter\ToInlineStyleEmailConverter;
1515
use Symfony\Component\Config\FileLocatorInterface;
16-
use Symfony\Component\Templating\TemplateNameParserInterface;
1716

1817
class InlineCssExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
1918
{
@@ -24,7 +23,7 @@ class InlineCssExtension extends \Twig_Extension implements \Twig_Extension_Glob
2423
/**
2524
* @var string
2625
*/
27-
private $kernelRoot;
26+
private $publicPath;
2827
/**
2928
* @var FileLocatorInterface
3029
*/
@@ -37,12 +36,12 @@ class InlineCssExtension extends \Twig_Extension implements \Twig_Extension_Glob
3736
public function __construct(
3837
ToInlineStyleEmailConverter $inlineCss,
3938
FileLocatorInterface $locator,
40-
$kernelRoot,
39+
$publicPath,
4140
$debug = false
4241
) {
4342
$this->inlineCss = $inlineCss;
4443
$this->locator = $locator;
45-
$this->kernelRoot = $kernelRoot;
44+
$this->publicPath = $publicPath;
4645
$this->debug = $debug;
4746
}
4847

@@ -51,7 +50,7 @@ public function __construct(
5150
*/
5251
public function getTokenParsers()
5352
{
54-
return array(new InlineCssParser($this->locator, $this->kernelRoot . '/../web', $this->debug));
53+
return array(new InlineCssParser($this->locator, $this->publicPath, $this->debug));
5554
}
5655

5756
/**

Twig/InlineCssParser.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace RobertoTru\ToInlineStyleEmailBundle\Twig;
1313

1414
use Symfony\Component\Config\FileLocatorInterface;
15-
use Symfony\Component\Templating\TemplateNameParserInterface;
1615
use Twig_Node;
1716
use Twig_Token;
1817

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "gushphp/to-inline-style-email-bundle",
33
"type": "symfony-bundle",
4-
"description": "A Symfony2 bundle for using the CssToInlineStyles translator by tijsverkoyen",
4+
"description": "A Symfony bundle for using the CssToInlineStyles translator by tijsverkoyen",
55
"keywords": ["css", "inline", "style", "email", "symfony", "bundle"],
66
"homepage": "http://github.com/gushphp/ToInlineStyleEmailBundle",
77
"license": "MIT",
@@ -19,7 +19,8 @@
1919
},
2020
"require-dev": {
2121
"symfony/framework-bundle": "*",
22-
"phpunit/phpunit": "^4.4"
22+
"phpunit/phpunit": "^4.4",
23+
"twig/twig": "*"
2324
},
2425
"autoload": {
2526
"psr-4": { "RobertoTru\\ToInlineStyleEmailBundle\\": "" }

0 commit comments

Comments
 (0)