first commit
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace KupShop\FeedGeneratorBundle\DependencyInjection\Compiler;
|
||||
|
||||
use KupShop\FeedGeneratorBundle\ContextPropertiesLocator;
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Check out https://symfony.com/doc/current/service_container/tags.html.
|
||||
*/
|
||||
class ContextPropertiesPass implements CompilerPassInterface
|
||||
{
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
// always first check if the primary service is defined
|
||||
if (!$container->has(ContextPropertiesLocator::class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$definition = $container->findDefinition(ContextPropertiesLocator::class);
|
||||
|
||||
// find all service IDs with the kupshop.feed.expression.functions tag
|
||||
$taggedServices = $container->findTaggedServiceIds('kupshop.feed.context.property');
|
||||
|
||||
foreach ($taggedServices as $id => $tags) {
|
||||
$class = $container->findDefinition($id)->getClass();
|
||||
$definition->addMethodCall('addContextProperty', [
|
||||
$id,
|
||||
$class::getName(),
|
||||
]);
|
||||
}
|
||||
|
||||
$definition->addMethodCall('sortContexts');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user