From 39b6bf654f29a942411c54ed7cabd9bca399ccc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edi=20Modri=C4=87?= Date: Wed, 22 Apr 2015 13:32:42 +0200 Subject: [PATCH] Workaround for eZ Publish configuration processor not being able to merge arrays with numeric indexes --- .../NetgenOpenGraphExtension.php | 17 +++++++++++++++++ MetaTag/Collector.php | 2 +- Resources/doc/CHANGELOG.md | 4 ++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/DependencyInjection/NetgenOpenGraphExtension.php b/DependencyInjection/NetgenOpenGraphExtension.php index d8e04c8..bd1b769 100644 --- a/DependencyInjection/NetgenOpenGraphExtension.php +++ b/DependencyInjection/NetgenOpenGraphExtension.php @@ -30,6 +30,23 @@ public function load( array $configs, ContainerBuilder $container ) $loader->load( 'defaults.yml' ); $loader->load( 'templating.yml' ); + // The following block is a workaround for eZ Publish configuration processor + // not being able to merge arrays with numeric indexes. + // It works by inserting a dummy 'all_content_types' subkey, basically converting + // the array from numeric based indexes to string based indexes. + if ( !empty( $config['system'] ) ) + { + foreach ( $config['system'] as $scope => &$handlers ) + { + if ( !empty( $handlers['global_handlers'] ) ) + { + $handlers['global_handlers'] = array( + 'all_content_types' => $handlers['global_handlers'] + ); + } + } + } + $processor = new ConfigurationProcessor( $container, 'netgen_open_graph' ); $processor->mapConfig( $config, diff --git a/MetaTag/Collector.php b/MetaTag/Collector.php index 202fe38..152db1b 100644 --- a/MetaTag/Collector.php +++ b/MetaTag/Collector.php @@ -60,7 +60,7 @@ public function collect( Content $content ) if ( isset( $contentTypeHandlers[$contentType->identifier] ) ) { $allHandlers = array_merge( - $allHandlers, + $allHandlers['all_content_types'], $contentTypeHandlers[$contentType->identifier] ); } diff --git a/Resources/doc/CHANGELOG.md b/Resources/doc/CHANGELOG.md index b2b2f8f..265d363 100644 --- a/Resources/doc/CHANGELOG.md +++ b/Resources/doc/CHANGELOG.md @@ -1,6 +1,10 @@ Netgen Open Graph Bundle changelog ================================== +## 1.0.2 (22.04.2015) + +* Fix an edge case bug where some handler configuration could be duplicated + ## 1.0.1 (22.04.2015) * Remove need for specifying image alias in `ezimage` field type handler