The method "unaliases" recursively to return a Definition instance.
public findDefinition ( string $id ) : |
||
$id | string | The service identifier or alias |
return | A Definition instance |
use Symfony\Component\DependencyInjection\ContainerBuilder; // create a new container builder $containerBuilder = new ContainerBuilder(); // register a new service definition $containerBuilder->register('my_service', 'My\Service\Class'); // find the definition of the 'my_service' service $definition = $containerBuilder->findDefinition('my_service');
use Symfony\Component\DependencyInjection\ContainerBuilder; // create a new container builder $containerBuilder = new ContainerBuilder(); // register multiple service definitions $containerBuilder->register('service_a', 'My\Service\ClassA'); $containerBuilder->register('service_b', 'My\Service\ClassB'); $containerBuilder->register('service_c', 'My\Service\ClassC'); // find the definition of the 'service_b' service $definition = $containerBuilder->findDefinition('service_b');In these examples, we create a new `ContainerBuilder` instance and register one or more service definitions using the `$containerBuilder->register()` method. We then use the `$containerBuilder->findDefinition()` method to retrieve the definition of a specific service by its ID. Overall, the `findDefinition` method is a useful tool for accessing and manipulating service definitions within the Symfony dependency injection container.
public findDefinition ( string $id ) : |
||
$id | string | The service identifier or alias |
return | A Definition instance |