for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Install GitHub App
<?php
declare(strict_types=1);
namespace Overblog\GraphQLBundle\DependencyInjection\Compiler;
use InvalidArgumentException;
use Overblog\GraphQLBundle\Definition\GraphQLServices;
use Overblog\GraphQLBundle\Generator\TypeGenerator;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use function is_string;
use function sprintf;
final class GraphQLServicesPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container): void
$taggedServices = $container->findTaggedServiceIds('overblog_graphql.service', true);
$serviceContainer = ['container' => new Reference('service_container')];
$expressionLanguageDefinition = $container->findDefinition('overblog_graphql.expression_language');
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $attributes) {
if (empty($attributes['alias']) || !is_string($attributes['alias'])) {
throw new InvalidArgumentException(
sprintf('Service "%s" tagged "overblog_graphql.service" should have a valid "alias" attribute.', $id)
);
}
$serviceContainer[$attributes['alias']] = new Reference($id);
$isPublic = isset($attributes['public']) ? (bool) $attributes['public'] : true;
if ($isPublic) {
$expressionLanguageDefinition->addMethodCall(
'addGlobalName',
[
sprintf(TypeGenerator::GRAPHQL_SERVICES.'->get(\'%s\')', $attributes['alias']),
$attributes['alias'],
]
$container->findDefinition(GraphQLServices::class)->addArgument($serviceContainer);