Html.php 866 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * This file is part of the ForkBB <https://github.com/forkbb>.
  4. *
  5. * @copyright (c) Visman <mio.visman@yandex.ru, https://github.com/MioVisman>
  6. * @license The MIT License (MIT)
  7. */
  8. declare(strict_types=1);
  9. namespace ForkBB\Models\Validators;
  10. use ForkBB\Core\RulesValidator;
  11. use ForkBB\Core\Validator;
  12. class Html extends RulesValidator
  13. {
  14. /**
  15. * Обрабатывает html код в соответствии с заданными правилами
  16. */
  17. public function html(Validator $v, string $value): string
  18. {
  19. $errors = [];
  20. $result = $this->c->HTMLCleaner->setConfig()->parse($value, $errors);
  21. if (empty($errors)) {
  22. return $result;
  23. } else {
  24. foreach ($errors as $args) {
  25. $v->addError($args);
  26. }
  27. return $value;
  28. }
  29. }
  30. }