Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

RichTextExtension.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension;
8
9 use eZ\Publish\Core\FieldType\RichText\Converter as RichTextConverterInterface;
10 use Twig_Extension;
11 use Twig_SimpleFilter;
12
13 class RichTextExtension extends Twig_Extension
14 {
16 private $richTextConverter;
17
19 private $richTextEditConverter;
20
21 public function __construct(RichTextConverterInterface $richTextConverter, RichTextConverterInterface $richTextEditConverter)
22 {
23 $this->richTextConverter = $richTextConverter;
24 $this->richTextEditConverter = $richTextEditConverter;
25 }
26
27 public function getName()
28 {
29 return 'ezpublish.rich_text';
30 }
31
32 public function getFilters()
33 {
34 return [
35 new Twig_SimpleFilter(
36 'richtext_to_html5',
37 [$this, 'richTextToHtml5'],
38 ['is_safe' => ['html']]
39 ),
40 new Twig_SimpleFilter(
41 'richtext_to_html5_edit',
42 [$this, 'richTextToHtml5Edit'],
43 ['is_safe' => ['html']]
44 ),
45 ];
46 }
47
55 public function richTextToHtml5($xmlData)
56 {
57 return $this->richTextConverter->convert($xmlData)->saveHTML();
58 }
59
67 public function richTextToHtml5Edit($xmlData)
68 {
69 return $this->richTextEditConverter->convert($xmlData)->saveHTML();
70 }
71 }
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension
Definition: RichTextExtension.php:14
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\$richTextEditConverter
$richTextEditConverter
Definition: RichTextExtension.php:19
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\richTextToHtml5
richTextToHtml5($xmlData)
Implements the "richtext_to_html5" filter.
Definition: RichTextExtension.php:55
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\getName
getName()
Definition: RichTextExtension.php:27
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\$richTextConverter
$richTextConverter
Definition: RichTextExtension.php:16
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\richTextToHtml5Edit
richTextToHtml5Edit($xmlData)
Implements the "richtext_to_html5_edit" filter.
Definition: RichTextExtension.php:67
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\getFilters
getFilters()
Definition: RichTextExtension.php:32
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension\RichTextExtension\__construct
__construct(RichTextConverterInterface $richTextConverter, RichTextConverterInterface $richTextEditConverter)
Definition: RichTextExtension.php:21
eZ\Publish\Core\FieldType\RichText\Converter
Definition: FieldType/RichText/Converter/Aggregate.php:7
eZ\Publish\Core\MVC\Symfony\Templating\Twig\Extension
Definition: ContentExtension.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.