Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Extraction] Added kernel 7.x compatibility code
- Loading branch information
Bertrand Dunogier
committed
Mar 28, 2018
1 parent
cd920c9
commit edc7e2a
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
60 changes: 60 additions & 0 deletions
60
src/bundle/DependencyInjection/Compiler/KernelRichTextPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) eZ Systems AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace EzSystems\EzPlatformRichTextFieldTypeBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
/** | ||
* Handles compatibility with kernel 7.x. | ||
*/ | ||
class KernelRichTextPass implements CompilerPassInterface | ||
{ | ||
private $servicesToRemove = [ | ||
'ezpublish.fieldType.ezrichtext', | ||
'ezpublish.fieldType.ezrichtext.converter', | ||
'ezpublish.fieldType.indexable.ezrichtext', | ||
'ezpublish_rest.field_type_processor.ezrichtext', | ||
'EzSystems\\RepositoryForms\\FieldType\\Mapper\\RichTextFormMapper', | ||
]; | ||
|
||
public function process(ContainerBuilder $container) | ||
{ | ||
array_map( | ||
function ($service) use ($container) { | ||
if ($container->hasDefinition($service)) { | ||
$container->log($this, "Removed ezpublish-kernel richtext service: $service"); | ||
$container->removeDefinition($service); | ||
} | ||
}, | ||
$this->servicesToRemove | ||
); | ||
|
||
$def = $container->getDefinition('ezpublish.persistence.legacy.field_value_converter.registry'); | ||
$methodCalls = []; | ||
foreach ($def->getMethodCalls() as $methodCall) { | ||
if ($methodCall[0] != 'register') { | ||
$methodCalls[] = $methodCall; | ||
continue; | ||
} | ||
|
||
if ($methodCall[1][0] != 'ezrichtext') { | ||
$methodCalls[] = $methodCall; | ||
continue; | ||
} | ||
|
||
if (!$methodCall[1][1] instanceof Reference || (string)$methodCall[1][1] !== 'ezpublish.fieldType.ezrichtext.converter') { | ||
$methodCalls[] = $methodCall; | ||
continue; | ||
} | ||
} | ||
$def->setMethodCalls($methodCalls); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters