Symfony\Component\DependencyInjection\ContainerBuilder::has PHP Method

has() public method

Returns true if the given service is defined.
public has ( string $id ) : boolean
$id string The service identifier
return boolean true if the service is defined, false otherwise
    public function has($id)
    {
        $id = strtolower($id);

        return isset($this->definitions[$id]) || isset($this->aliasDefinitions[$id]) || parent::has($id);
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $container->getParameterBag()->remove('cache.prefix.seed');
     foreach ($container->findTaggedServiceIds('cache.pool') as $id => $attributes) {
         foreach (array_reverse($attributes) as $attr) {
             if (isset($attr['clearer'])) {
                 $clearer = $container->getDefinition($attr['clearer']);
                 $clearer->addMethodCall('addPool', array(new Reference($id)));
             }
             if (array_key_exists('clearer', $attr)) {
                 break;
             }
         }
     }
     if (!$container->has('cache.annotations')) {
         return;
     }
     $factory = array(AbstractAdapter::class, 'createSystemCache');
     $annotationsPool = $container->getDefinition('cache.annotations');
     if ($factory !== $annotationsPool->getFactory() || 4 !== count($annotationsPool->getArguments())) {
         return;
     }
     if ($container->has('monolog.logger.cache')) {
         $annotationsPool->addArgument(new Reference('monolog.logger.cache'));
     } elseif ($container->has('cache.system')) {
         $systemPool = $container->getDefinition('cache.system');
         if ($factory === $systemPool->getFactory() && 5 <= count($systemArgs = $systemPool->getArguments())) {
             $annotationsPool->addArgument($systemArgs[4]);
         }
     }
 }
All Usage Examples Of Symfony\Component\DependencyInjection\ContainerBuilder::has