Skip to content

Commit

Permalink
Added run-time support for old ezno namepaces
Browse files Browse the repository at this point in the history
  • Loading branch information
vidarl committed Feb 6, 2023
1 parent 06d8757 commit 54a4767
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ public function process(ContainerBuilder $container)
);
$this->setConverterDefinitions($taggedInputServiceIds, $html5InputConverterDefinition);
}

if ($container->hasDefinition('ibexa.richtext.converter.edit.xhtml5')) {
$html5EditConverterDefinition = $container->getDefinition('ibexa.richtext.converter.edit.xhtml5');
$taggedInputServiceIds = $container->findTaggedServiceIds(
'ibexa.field_type.richtext.converter.edit.xhtml5'
);
$this->setConverterDefinitions($taggedInputServiceIds, $html5EditConverterDefinition);
}
}

/**
Expand Down
15 changes: 15 additions & 0 deletions src/bundle/Resources/config/fieldtype_services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,26 @@ services:
tags:
- {name: ibexa.field_type.richtext.converter.input.xhtml5, priority: 10}

# Aggregate converter for XHTML5 edit that other converters register to
# through 'ibexa.field_type.richtext.converter.edit.xhtml5' service tag.
ibexa.richtext.converter.edit.xhtml5:
class: Ibexa\FieldTypeRichText\RichText\Converter\Aggregate
lazy: true

Ibexa\FieldTypeRichText\RichText\Converter\Html5Edit:
class: Ibexa\FieldTypeRichText\RichText\Converter\Html5Edit
arguments:
- '%ibexa.field_type.richtext.converter.edit.xhtml5.resources%'
- '@ibexa.config.resolver'
tags:
- {name: ibexa.field_type.richtext.converter.edit.xhtml5, priority: 100}

# Note: should run before xsl transformation
Ibexa\FieldTypeRichText\RichText\Converter\EzNoNamespace:
class: Ibexa\FieldTypeRichText\RichText\Converter\EzNoNamespace
tags:
- {name: ibexa.field_type.richtext.converter.output.xhtml5, priority: -15}
- {name: ibexa.field_type.richtext.converter.edit.xhtml5, priority: -15}

Ibexa\Bundle\FieldTypeRichText\Command\MigrateNamespacesCommand:
autowire: true
Expand Down
4 changes: 2 additions & 2 deletions src/bundle/Resources/config/form.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ services:

Ibexa\FieldTypeRichText\Form\Type\RichTextFieldType:
arguments:
$docbookToXhtml5EditConverter: '@Ibexa\FieldTypeRichText\RichText\Converter\Html5Edit'
$docbookToXhtml5EditConverter: '@ibexa.richtext.converter.edit.xhtml5'
$fieldTypeService: '@ibexa.api.service.field_type'

Ibexa\FieldTypeRichText\Form\Type\RichTextType:
arguments:
$docbookToXhtml5EditConverter: '@Ibexa\FieldTypeRichText\RichText\Converter\Html5Edit'
$docbookToXhtml5EditConverter: '@ibexa.richtext.converter.edit.xhtml5'

Ibexa\FieldTypeRichText\Validator\Constraints\RichTextValidator:
tags:
Expand Down
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/rest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ services:

Ibexa\FieldTypeRichText\REST\FieldTypeProcessor\RichTextProcessor:
arguments:
- '@Ibexa\FieldTypeRichText\RichText\Converter\Html5Edit'
- '@ibexa.richtext.converter.edit.xhtml5'
tags:
- { name: ibexa.rest.field_type.processor, alias: ezrichtext }
2 changes: 1 addition & 1 deletion src/bundle/Resources/config/templating.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ services:
Ibexa\Bundle\FieldTypeRichText\Templating\Twig\Extension\RichTextConverterExtension:
arguments:
$richTextOutputConverter: '@ibexa.richtext.converter.output.xhtml5'
$richTextEditConverter: '@Ibexa\FieldTypeRichText\RichText\Converter\Html5Edit'
$richTextEditConverter: '@ibexa.richtext.converter.edit.xhtml5'

Ibexa\Bundle\FieldTypeRichText\Templating\Twig\Extension\YoutubeIdExtractorExtension: ~

Expand Down
25 changes: 25 additions & 0 deletions src/lib/RichText/Converter/EzNoNamespace.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);

namespace Ibexa\FieldTypeRichText\RichText\Converter;

use DOMDocument;
use Ibexa\Contracts\FieldTypeRichText\RichText\Converter;

class EzNoNamespace implements Converter
{
public function convert(DOMDocument $xmlDoc)
{
$xml = $xmlDoc->saveXML();
$xml = str_replace('xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"', 'xmlns:ezxhtml="http://ibexa.co/xmlns/dxp/docbook/xhtml"', $xml);
$xml = str_replace('xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom"', 'xmlns:ezcustom="http://ibexa.co/xmlns/dxp/docbook/custom"', $xml);
$xmlDoc->loadXML($xml);

return $xmlDoc;
}
}

0 comments on commit 54a4767

Please sign in to comment.