1 | <?php |
||
25 | final class HtmlBlockRenderer implements BlockRendererInterface, ConfigurationAwareInterface |
||
26 | { |
||
27 | /** |
||
28 | * @var ConfigurationInterface |
||
29 | */ |
||
30 | protected $config; |
||
31 | |||
32 | * @param HtmlBlock $block |
||
|
|||
33 | * @param NodeRendererInterface $htmlRenderer |
||
34 | * @param bool $inTightList |
||
35 | * |
||
36 | * @return string |
||
37 | */ |
||
38 | public function render(AbstractBlock $block, NodeRendererInterface $htmlRenderer, bool $inTightList = false) |
||
39 | { |
||
40 | if (!($block instanceof HtmlBlock)) { |
||
41 | throw new \InvalidArgumentException('Incompatible block type: ' . \get_class($block)); |
||
42 | } |
||
43 | |||
44 | if ($this->config->get('html_input') === EnvironmentInterface::HTML_INPUT_STRIP) { |
||
45 | return ''; |
||
46 | } |
||
47 | |||
48 | if ($this->config->get('html_input') === EnvironmentInterface::HTML_INPUT_ESCAPE) { |
||
49 | return \htmlspecialchars($block->getStringContent(), \ENT_NOQUOTES); |
||
50 | } |
||
51 | |||
52 | return $block->getStringContent(); |
||
53 | } |
||
54 | |||
55 | public function setConfiguration(ConfigurationInterface $configuration): void |
||
56 | { |
||
57 | $this->config = $configuration; |
||
58 | } |
||
59 | } |
||
60 |