Skip to content

Commit 2b35301

Browse files
authored
Symfony 4 support (#18)
1 parent 0ee1ca9 commit 2b35301

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
],
1515
"require": {
1616
"php": ">=5.3.9",
17-
"symfony/framework-bundle": "~2.3||3.*",
17+
"symfony/framework-bundle": "~2.3||3.*||4.*",
1818
"caxy/php-htmldiff": "~0.1"
1919
},
2020
"require-dev": {

src/Resources/config/services.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ services:
77
caxy.html_diff.config:
88
class: "%caxy.html_diff.config.class%"
99
factory: ["%caxy.html_diff.config.class%", create]
10+
public: true
1011
caxy.html_diff:
1112
class: "%caxy.html_diff.class%"
13+
public: true
1214
calls:
1315
- [setConfig, ["@caxy.html_diff.config"]]
1416
caxy.twig.html_diff_extension:
1517
class: "%caxy.twig.html_diff_extension.class%"
16-
arguments: ["@service_container"]
18+
arguments: ["@caxy.html_diff"]
19+
public: true
1720
tags:
1821
- { name: twig.extension }

src/Twig/HtmlDiffExtension.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,23 @@
22

33
namespace Caxy\HtmlDiffBundle\Twig;
44

5-
use Symfony\Component\DependencyInjection\ContainerInterface;
5+
use Caxy\HtmlDiffBundle\Service\HtmlDiffService;
66

77
class HtmlDiffExtension extends \Twig_Extension
88
{
99
protected $container;
1010

1111
protected $htmlDiff;
1212

13-
public function __construct(ContainerInterface $container)
13+
public function __construct(HtmlDiffService $htmlDiff)
1414
{
15-
$this->container = $container;
16-
$this->htmlDiff = $this->container->get('caxy.html_diff');
15+
$this->htmlDiff = $htmlDiff;
1716
}
1817

1918
public function getFunctions()
2019
{
2120
return array(
22-
new \Twig_SimpleFunction('htmldiff', array($this, 'htmlDiff')),
21+
new \Twig_SimpleFunction('htmldiff', array($this, 'htmlDiff'), array('is_safe' => array('html'))),
2322
);
2423
}
2524

0 commit comments

Comments
 (0)