Skip to content

Commit

Permalink
Fix issue with only being possible to add one handler of the same typ…
Browse files Browse the repository at this point in the history
…e to content type/global handlers
  • Loading branch information
emodric committed Apr 22, 2015
1 parent 7f433d4 commit 8ef6ac3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
10 changes: 8 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,13 @@ public function getConfigTreeBuilder()
->normalizeKeys( false )
->prototype( 'array' )
->requiresAtLeastOneElement()
->useAttributeAsKey( 'handler' )
->normalizeKeys( false )
->prototype( 'array' )
->children()
->scalarNode( 'handler' )
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode( 'tag' )
->isRequired()
->cannotBeEmpty()
Expand All @@ -44,10 +47,13 @@ public function getConfigTreeBuilder()
->end()
->end()
->arrayNode( 'global_handlers' )
->useAttributeAsKey( 'handler' )
->normalizeKeys( false )
->prototype( 'array' )
->children()
->scalarNode( 'handler' )
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode( 'tag' )
->isRequired()
->cannotBeEmpty()
Expand Down
6 changes: 3 additions & 3 deletions MetaTag/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function collect( Content $content )
);
}

foreach ( $allHandlers as $handlerName => $handler )
foreach ( $allHandlers as $handler )
{
$metaTagHandler = $this->metaTagHandlers->getHandler( $handlerName );
$metaTagHandler = $this->metaTagHandlers->getHandler( $handler['handler'] );
if ( $metaTagHandler instanceof ContentAware )
{
$metaTagHandler->setContent( $content );
Expand All @@ -79,7 +79,7 @@ public function collect( Content $content )
if ( !$metaTag instanceof Item )
{
throw new LogicException(
'\'' . $handlerName . '\' handler returned wrong value.' .
'\'' . $handler['handler'] . '\' handler returned wrong value.' .
' Expected \'Netgen\Bundle\OpenGraphBundle\MetaTag\Item\', got \'' . get_class( $metaTag ) . '\'.' );
}

Expand Down
4 changes: 4 additions & 0 deletions Resources/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Netgen Open Graph Bundle changelog
==================================

## 1.0.1 (22.04.2015)

* Fix issue with being able to add only one handler of the same type

## 1.0 (21.11.2014)

* Initial release

0 comments on commit 8ef6ac3

Please sign in to comment.