‪TYPO3CMS  10.4
SanitizerBuilderFactory.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 project.
7  *
8  * It is free software; you can redistribute it and/or modify it under the terms
9  * of the MIT License (MIT). For the full copyright and license information,
10  * please read the LICENSE file that was distributed with this source code.
11  *
12  * The TYPO3 project - inspiring people to share!
13  */
14 
15 namespace ‪TYPO3\CMS\Core\Html;
16 
17 use LogicException;
19 use TYPO3\HtmlSanitizer\Builder\BuilderInterface;
20 
35 {
39  protected ‪$configuration;
40 
41  public function ‪__construct(array ‪$configuration = null)
42  {
43  $this->configuration = ‪$configuration ?? ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['htmlSanitizer'] ?? [];
44  }
45 
46  public function ‪build(string $identifier): BuilderInterface
47  {
48  if (empty($this->configuration[$identifier])) {
49  throw new LogicException(
50  sprintf('Undefined `htmlSanitizer` identifier `%s`', $identifier),
51  1624876139
52  );
53  }
54  $builder = GeneralUtility::makeInstance($this->configuration[$identifier]);
55  if (!$builder instanceof BuilderInterface) {
56  throw new LogicException(
57  sprintf(
58  'Builder `%s` must implement interface `%s`',
59  get_class($builder),
60  BuilderInterface::class
61  ),
62  1624876266
63  );
64  }
65  return $builder;
66  }
67 }
‪TYPO3\CMS\Core\Html
Definition: DefaultSanitizerBuilder.php:15
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory\$configuration
‪array $configuration
Definition: SanitizerBuilderFactory.php:38
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory\build
‪build(string $identifier)
Definition: SanitizerBuilderFactory.php:45
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory\__construct
‪__construct(array $configuration=null)
Definition: SanitizerBuilderFactory.php:40
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory
Definition: SanitizerBuilderFactory.php:35