Skip to content

Commit

Permalink
[Symfony] Prepended ezplatform configuration to ezpublish extension
Browse files Browse the repository at this point in the history
This is a workaround to avoid copying all the code from
EzPublishCoreBundle at once. It allows using "ezplatform"
as a root node for the configuration w/o defining that configuration.

Validation is still done by ezpublish extension.
  • Loading branch information
alongosz committed Sep 30, 2019
1 parent 9aa786d commit 7508f87
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder(EzPlatformCoreExtension::EXTENSION_ALIAS);
$treeBuilder = new TreeBuilder();

$rootNode = $treeBuilder->getRootNode();
$rootNode = $treeBuilder->root(EzPlatformCoreExtension::EXTENSION_ALIAS);

// @todo define actual configuration (move from EzPublishCoreBundle)
$rootNode->variablePrototype();

return $treeBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,40 @@
use Symfony\Component\Config\Definition\ConfigurationInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;

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

public function load(array $configs, ContainerBuilder $container): void
{
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
}

public function getConfiguration(array $config, ContainerBuilder $container): ConfigurationInterface
{
public function getConfiguration(
array $config,
ContainerBuilder $container
): ConfigurationInterface {
return new Configuration();
}

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

/**
* Prepend "ezplatform" configuration to "ezpublish" configuration.
*
* @todo remove once we replace EzPublishCoreBundle with EzPlatformCoreBundle
*/
public function prepend(ContainerBuilder $container): void
{
// inject "ezplatform" extension settings into "ezpublish" extension
// configuration here is zero-based array of configurations from multiple sources
// to be merged by "ezpublish" extension
foreach ($container->getExtensionConfig('ezplatform') as $eZPlatformConfig) {
$container->prependExtensionConfig('ezpublish', $eZPlatformConfig);
}
}
}

0 comments on commit 7508f87

Please sign in to comment.