Skip to content

Commit

Permalink
IBX-88: Restored BC layer for ezplatform Semantic config
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Nov 25, 2021
1 parent 2f10239 commit ebe9a62
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/bundle/DependencyInjection/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public function prependExtensionConfig(string $name, array $config): void

private function resolveExtensionName(string $name): string
{
return self::EXTENSION_NAME_BC_MAP[$name] ?? $name;
$name = self::EXTENSION_NAME_BC_MAP[$name] ?? $name;

// fallback for not loaded yet ibexa extension
// @todo remove once the new extension name is merged into the codebase
if ($name === 'ibexa' && !parent::hasExtension('ibexa')) {
return 'ezpublish';
}

return $name;
}
}
43 changes: 43 additions & 0 deletions src/bundle/DependencyInjection/Extension/PlatformExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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\Bundle\CompatibilityLayer\DependencyInjection\Extension;

use Ibexa\Bundle\CompatibilityLayer\DependencyInjection\ContainerBuilder as IbexaContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;

final class PlatformExtension extends Extension implements PrependExtensionInterface
{
public const EXTENSION_ALIAS = 'ezplatform';

public function load(array $configs, ContainerBuilder $container): void
{
}

public function getAlias(): string
{
return self::EXTENSION_ALIAS;
}

public function prepend(ContainerBuilder $container): void
{
if ($container instanceof IbexaContainerBuilder) {
// Nothing to do, BC is handled by Ibexa ContainerBuilder
return;
}

$currentExtensionName = $container->hasExtension('ibexa') ? 'ibexa' : 'ezpublish';
foreach ($container->getExtensionConfig('ezplatform') as $legacyExtensionConfig) {
$container->prependExtensionConfig($currentExtensionName, $legacyExtensionConfig);
}
}
}

class_alias(PlatformExtension::class, 'EzSystems\EzPlatformCoreBundle\DependencyInjection\EzPlatformCoreExtension');
3 changes: 3 additions & 0 deletions src/bundle/IbexaCompatibilityLayerBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Ibexa\Bundle\CompatibilityLayer\DependencyInjection\Compiler\ServiceCompatibilityPass;
use Ibexa\Bundle\CompatibilityLayer\DependencyInjection\Compiler\TwigPass;
use Ibexa\Bundle\CompatibilityLayer\DependencyInjection\Compiler\ValueObjectVisitorTagCompatibilityPass;
use Ibexa\Bundle\CompatibilityLayer\DependencyInjection\Extension\PlatformExtension;
use Ibexa\CompatibilityLayer\BundleResolver\BundleNameResolver;
use Ibexa\CompatibilityLayer\FullyQualifiedNameResolver\AggregateResolver;
use Ibexa\CompatibilityLayer\FullyQualifiedNameResolver\ClassMapResolver;
Expand All @@ -29,6 +30,8 @@ public function build(ContainerBuilder $container)
{
parent::build($container);

$container->registerExtension(new PlatformExtension());

$fullyQualifiedNameResolver = new AggregateResolver([
new ClassMapResolver(),
new PSR4PrefixResolver(),
Expand Down

0 comments on commit ebe9a62

Please sign in to comment.