Skip to content

Commit 8d4d56b

Browse files
authored
Merge pull request #1 from bluetel/ez3
Ez3
2 parents 7d1aa39 + 4a9501f commit 8d4d56b

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313
"psr-4": {"spec\\Inviqa\\EzTextEnhancerBundle\\": "spec"}
1414
},
1515
"require": {
16-
"php": "~5.5|~7.0",
17-
"symfony/framework-bundle": "^2.8",
18-
"symfony/twig-bundle": "^2.8",
19-
"ezsystems/ezpublish-kernel": "^6.5"
16+
"php": "^7.4",
17+
"symfony/framework-bundle": "^5.0",
18+
"symfony/twig-bundle": "^5.0",
19+
"ezsystems/ezplatform-kernel": "~1.1.2",
20+
"ezsystems/ezplatform-richtext": "~2.1.1"
2021
},
2122
"require-dev": {
22-
"phpspec/phpspec": "^3.1"
23+
"phpspec/phpspec": "^6.3.0"
2324
}
2425
}

spec/Twig/TwigTextEnhancerExtensionSpec.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
namespace spec\Inviqa\EzTextEnhancerBundle\Twig;
44

5-
use eZ\Publish\Core\FieldType\RichText\Converter;
5+
use EzSystems\EzPlatformRichText\eZ\RichText\Converter;
66
use Inviqa\EzTextEnhancerBundle\TextEnhancer;
77
use Inviqa\EzTextEnhancerBundle\Twig\TwigTextEnhancerExtension;
88
use PhpSpec\ObjectBehavior;
99
use Prophecy\Argument;
1010
use Symfony\Component\DependencyInjection\ContainerInterface;
11+
use Twig\TwigFilter;
1112

1213
class TwigTextEnhancerExtensionSpec extends ObjectBehavior
1314
{
@@ -49,7 +50,7 @@ function it_converts_the_text_and_then_it_enhances_it_if_DOMDocument_is_received
4950
$this->enhanceText($inputDocument)->shouldReturn('<p>my <strong>enhanced</strong> text</p>');
5051
}
5152

52-
public function getMatchers()
53+
public function getMatchers(): array
5354
{
5455
return [
5556
'returnTheFilters' => function ($filters, $expected)
@@ -63,7 +64,7 @@ public function getMatchers()
6364
}
6465

6566
for ($i = 0; $i < count($filters); $i++) {
66-
if (!$filters[$i] instanceof \Twig_SimpleFilter) {
67+
if (!$filters[$i] instanceof TwigFilter) {
6768
return false;
6869
}
6970

src/Resources/config/services.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
<services>
88
<service id="inviqa.text_enhancer.chain_text_enhancer"
9-
class="Inviqa\EzTextEnhancerBundle\TextEnhancer\ChainTextEnhancer">
9+
class="Inviqa\EzTextEnhancerBundle\TextEnhancer\ChainTextEnhancer"
10+
public="true">
1011
</service>
1112

1213
<service id="inviqa.text_enhancer.twig_extension"
1314
class="Inviqa\EzTextEnhancerBundle\Twig\TwigTextEnhancerExtension">
14-
<argument type="service" id="ezpublish.fieldtype.ezrichtext.converter.output.xhtml5" />
15+
<argument type="service" id="ezrichtext.converter.output.xhtml5.core" />
1516
<argument type="service" id="service_container" />
1617
<tag name="twig.extension" />
1718
</service>

src/Twig/TwigTextEnhancerExtension.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
namespace Inviqa\EzTextEnhancerBundle\Twig;
44

5-
use eZ\Publish\Core\FieldType\RichText\Converter;
5+
use EzSystems\EzPlatformRichText\eZ\RichText\Converter;
66
use Inviqa\EzTextEnhancerBundle\TextEnhancer;
77
use Symfony\Component\DependencyInjection\ContainerInterface;
8+
use Twig\Extension\AbstractExtension;
9+
use Twig\TwigFilter;
810

911
/**
1012
* Unfortunately, Twig extensions (like that one) are attached to the twig service. The drawback of this situation
@@ -16,7 +18,7 @@
1618
* expect many dependencies, we prefer to keep the "dirty" solution in a single place. THIS IS WHY THIS SERVICE REQUIRES
1719
* THE CONTAINER.
1820
*/
19-
final class TwigTextEnhancerExtension extends \Twig_Extension
21+
final class TwigTextEnhancerExtension extends AbstractExtension
2022
{
2123
const TEXT_ENHANCER_SERVICE_ID = 'inviqa.text_enhancer.chain_text_enhancer';
2224

@@ -64,7 +66,7 @@ public function getName()
6466
public function getFilters()
6567
{
6668
return [
67-
new \Twig_SimpleFilter('enhance_text', [$this, 'enhanceText'], ['is_safe' => ['all']]),
69+
new TwigFilter('enhance_text', [$this, 'enhanceText'], ['is_safe' => ['all']]),
6870
];
6971
}
7072

0 commit comments

Comments
 (0)