diff --git a/src/lib/RichText/Validator/CustomTemplateValidator.php b/src/lib/RichText/Validator/CustomTemplateValidator.php index ce4d049c..1d7a86c0 100644 --- a/src/lib/RichText/Validator/CustomTemplateValidator.php +++ b/src/lib/RichText/Validator/CustomTemplateValidator.php @@ -22,20 +22,6 @@ */ final class CustomTemplateValidator implements ValidatorInterface { - /** - * Custom Tags global configuration (ibexa.richtext.custom_tags Semantic Config). - * - * @var array}> - */ - private array $customTagsConfiguration; - - /** - * Custom Styles global configuration (ibexa.richtext.custom_styles Semantic Config). - * - * @var array - */ - private array $customStylesConfiguration; - /** * CustomTemplateValidator constructor. * @@ -43,11 +29,9 @@ final class CustomTemplateValidator implements ValidatorInterface * @param array $customStylesConfiguration */ public function __construct( - array $customTagsConfiguration, - array $customStylesConfiguration + private readonly array $customTagsConfiguration, + private readonly array $customStylesConfiguration ) { - $this->customTagsConfiguration = $customTagsConfiguration; - $this->customStylesConfiguration = $customStylesConfiguration; } /** @@ -76,16 +60,12 @@ public function validateDocument(DOMDocument $xmlDocument): array } if (!in_array($tagName, $configuredTemplateNames, true)) { - @trigger_error( - "Configuration for RichText Custom Tag or Custom Style '{$tagName}' not found. " . - 'Custom Tags and Custom Style configuration is required since 7.1, its lack will result in validation error in 8.x', - E_USER_DEPRECATED - ); + $errors[] = "Missing configuration for RichText CustomTag or CustomStyle: '$tagName'"; continue; } // Custom Styles does not have any attributes, so we can skip validation for them - if (isset($this->customStylesConfiguration[$tagName])) { + if(isset($this->customStylesConfiguration[$tagName])) { continue; } diff --git a/tests/lib/RichText/Validator/CustomTemplateValidatorTest.php b/tests/lib/RichText/Validator/CustomTemplateValidatorTest.php index 3a5148fd..4f3afd29 100644 --- a/tests/lib/RichText/Validator/CustomTemplateValidatorTest.php +++ b/tests/lib/RichText/Validator/CustomTemplateValidatorTest.php @@ -14,11 +14,9 @@ use Symfony\Component\Yaml\Yaml; /** - * Test RichText CustomTemplateValidator. - * - * @see \Ibexa\FieldTypeRichText\FieldType\RichText\CustomTemplateValidator + * @covers \Ibexa\FieldTypeRichText\FieldType\RichText\CustomTemplateValidator */ -class CustomTemplateValidatorTest extends TestCase +final class CustomTemplateValidatorTest extends TestCase { private CustomTemplateValidator $validator; @@ -127,7 +125,9 @@ public function providerForTestValidateDocument(): array DOCBOOK ), - [], + [ + "Missing configuration for RichText CustomTag or CustomStyle: 'non_existing_style'", + ], ], [ $this->createDocument( @@ -205,6 +205,7 @@ public function providerForTestValidateDocument(): array ), [ 'Missing RichText Custom Tag name', + "Missing configuration for RichText CustomTag or CustomStyle: 'undefined_tag'", "Missing attribute name for RichText Custom Tag 'video'", "The attribute 'title' of RichText Custom Tag 'video' cannot be empty", "The attribute 'width' of RichText Custom Tag 'video' cannot be empty", @@ -214,31 +215,6 @@ public function providerForTestValidateDocument(): array ]; } - /** - * Test that defined but not configured yet Custom Tag doesn't cause validation error. - */ - public function testValidateDocumentAcceptsLegacyTags(): void - { - $document = $this->createDocument( - << -
- - Undefined - - Test - - -
-DOCBOOK - ); - - self::assertEmpty($this->validator->validateDocument($document)); - } - protected function createDocument(string $source): DOMDocument { $document = new DOMDocument();