Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #711 from schmittjoh/exp-function-provider-tag
Allow to add expression function providers using DI tags
- Loading branch information
Showing
5 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
DependencyInjection/Compiler/ExpressionFunctionProviderPass.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,28 @@ | ||
<?php | ||
|
||
namespace JMS\SerializerBundle\DependencyInjection\Compiler; | ||
|
||
use Hateoas\Configuration\Provider\RelationProviderInterface; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class ExpressionFunctionProviderPass implements CompilerPassInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
try { | ||
$registryDefinition = $container->findDefinition('jms_serializer.expression_language'); | ||
|
||
foreach (array_keys($container->findTaggedServiceIds('jms.expression.function_provider')) as $id) { | ||
$registryDefinition->addMethodCall('registerProvider', [new Reference($id)]); | ||
} | ||
} catch (ServiceNotFoundException $exception){ | ||
|
||
} | ||
} | ||
} |
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
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