Skip to content

Conversation

@ViniTou
Copy link
Contributor

@ViniTou ViniTou commented Jan 27, 2026

🎫 Issue IBX-10827

Description:

  • Adds extensibility for the RichText DocBook schema (ezpublish.rng) via semantic configuration
  • Enables other bundles to register custom schema fragments that extend the base RichText validation schema
  • Allows custom embed types to be added through configuration

Configuration Example

In a custom bundle's config

parameters:                                                                                                                                                                                                                                                                
    ibexa.field_type.richtext.docbook.schema_fragments:                                                                                                                                                                                                                    
        - '%kernel.project_dir%/src/Bundle/MyBundle/Resources/richtext/my_custom_elements.rng'                                                                                                                                                                             
                                                                                                                                                                                                                                                                           
ibexa:                                                                                                                                                                                                                                                                     
    system:                                                                                                                                                                                                                                                                
        default:                                                                                                                                                                                                                                                           
            fieldtypes:                                                                                                                                                                                                                                                    
                ezrichtext:                                                                                                                                                                                                                                                
                    embed:                                                                                                                                                                                                                                                 
                        product:  # Custom embed type                                                                                                                                                                                                                      
                            template: '@MyBundle/richtext/embed/product.html.twig'                                                                                                                                                                                         

How It Works

  1. Schema fragments are registered via ibexa.field_type.richtext.docbook.schema_fragments parameter
  2. A compiler pass generates a combined schema in cache, including base schema + fragments
  3. Extension points (ez.extension.blocks, ez.extension.inlines) are made combinable via combine="choice"
  4. Custom embed types require a template key in configuration

Example output rng

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
       xmlns:db="http://docbook.org/ns/docbook"
       xmlns:ez="http://ibexa.co/xmlns/ezpublish/docbook"
       xmlns:ezxhtml="http://ibexa.co/xmlns/dxp/docbook/xhtml"
       xmlns:ezcustom="http://ibexa.co/xmlns/dxp/docbook/custom"
       xmlns:xlink="http://www.w3.org/1999/xlink"
       ns="http://docbook.org/ns/docbook"
       datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">

<include href="/var/www/html/vendor/ibexa/fieldtype-richtext/src/bundle/Resources/richtext/schemas/docbook/ezpublish.rng">
  <!-- Override extension points to make them combinable if they are not already -->
  <define name="ez.extension.blocks" combine="choice">
    <notAllowed/>
  </define>
  <define name="ez.extension.inlines" combine="choice">
    <notAllowed/>
  </define>
</include>
<include href="/var/www/html/vendor/ibexa/product-catalog/src/bundle/Resources/richtext/schemas/docbook/product_elements.rng"/>

</grammar>

For QA:

Documentation:

@ViniTou ViniTou requested a review from a team January 28, 2026 07:23
@ibexa-workflow-automation-1 ibexa-workflow-automation-1 bot requested review from Steveb-p, alongosz, barw4, ciastektk, konradoboza, mikadamczyk, tbialcz and wiewiurdp and removed request for a team January 28, 2026 07:23
@sonarqubecloud
Copy link

@ViniTou ViniTou added the Doc needed The changes require some documentation label Jan 28, 2026
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

final class RichTextDocbookSchemaPass implements CompilerPassInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
final class RichTextDocbookSchemaPass implements CompilerPassInterface
final readonly class RichTextDocbookSchemaPass implements CompilerPassInterface

Comment on lines +16 to +17
# Schema fragments to include (paths to RNG files)
ibexa.field_type.richtext.docbook.schema_fragments: []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed if CompilerPass fallbacks to an empty array?


$dir = dirname($outputPath);
if (!is_dir($dir)) {
mkdir($dir, 0777, true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't those permissions too forgiving? Maybe after saving the file we should change those to 644. It just raises an eyebrow when looking at "7" passed as permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Doc needed The changes require some documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants