‪TYPO3CMS  ‪main
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 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
18 namespace ‪TYPO3\CMS\Core\Html;
19 
21 use TYPO3\HtmlSanitizer\Builder\BuilderInterface;
22 
37 {
41  protected ‪$configuration;
42 
43  public function ‪__construct(array ‪$configuration = null)
44  {
45  $this->configuration = ‪$configuration ?? ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['htmlSanitizer'] ?? [];
46  }
47 
48  public function ‪build(string ‪$identifier): BuilderInterface
49  {
50  if (empty($this->configuration[‪$identifier])) {
51  throw new \LogicException(
52  sprintf('Undefined `htmlSanitizer` identifier `%s`', ‪$identifier),
53  1624876139
54  );
55  }
56  $builder = GeneralUtility::makeInstance($this->configuration[‪$identifier]);
57  if (!$builder instanceof BuilderInterface) {
58  throw new \LogicException(
59  sprintf(
60  'Builder `%s` must implement interface `%s`',
61  get_class($builder),
62  BuilderInterface::class
63  ),
64  1624876266
65  );
66  }
67  return $builder;
68  }
69 }
‪TYPO3\CMS\Core\Html
Definition: DefaultSanitizerBuilder.php:18
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory\$configuration
‪array $configuration
Definition: SanitizerBuilderFactory.php:40
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory\build
‪build(string $identifier)
Definition: SanitizerBuilderFactory.php:47
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory\__construct
‪__construct(array $configuration=null)
Definition: SanitizerBuilderFactory.php:42
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Html\SanitizerBuilderFactory
Definition: SanitizerBuilderFactory.php:37
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37