Skip to content

Commit 56b584c

Browse files
committed
do not fail with twig 3
1 parent 3bd469e commit 56b584c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
44

55
## Unreleased
66

7+
### Fixed
8+
9+
- Avoid conflict with Twig 3.
10+
711
### Added
812

913
- Configured clients are now tagged with `'httplug.client'`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"symfony/stopwatch": "^3.4.20 || ^4.2.1",
6464
"symfony/twig-bundle": "^3.4.20 || ^4.2.1",
6565
"symfony/web-profiler-bundle": "^3.4.20 || ^4.2.1",
66-
"twig/twig": "^1.41 || ^2.10"
66+
"twig/twig": "^1.41 || ^2.10 || ^3.0"
6767
},
6868
"suggest": {
6969
"php-http/cache-plugin": "To configure clients that cache responses",

src/Collector/Twig/HttpMessageMarkupExtension.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
namespace Http\HttplugBundle\Collector\Twig;
44

5+
use Twig\Extension\AbstractExtension;
6+
use Twig\TwigFilter;
7+
8+
if (!\class_exists(AbstractExtension::class)) {
9+
class_alias(\Twig_Extension::class, AbstractExtension::class);
10+
}
11+
if (!\class_exists(TwigFilter::class)) {
12+
class_alias(\Twig_SimpleFilter::class, TwigFilter::class);
13+
}
14+
515
/**
616
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
717
*/
8-
class HttpMessageMarkupExtension extends \Twig_Extension
18+
class HttpMessageMarkupExtension extends AbstractExtension
919
{
1020
/**
1121
* {@inheritdoc}
@@ -15,7 +25,7 @@ class HttpMessageMarkupExtension extends \Twig_Extension
1525
public function getFilters()
1626
{
1727
return [
18-
new \Twig_SimpleFilter('httplug_markup', [$this, 'markup'], ['is_safe' => ['html']]),
28+
new TwigFilter('httplug_markup', [$this, 'markup'], ['is_safe' => ['html']]),
1929
];
2030
}
2131

0 commit comments

Comments
 (0)