use Symfony\Component\DependencyInjection\Definition; // Create a new service definition with "container" scope $definition = new Definition(MyService::class); $definition->setScope('container'); // Get the scope of the service definition $serviceScope = $definition->getScope(); // returns "container"
use Symfony\Component\DependencyInjection\Definition; // Create a new service definition with "prototype" scope $definition = new Definition(MyService::class); $definition->setScope('prototype'); // Get the scope of the service definition $serviceScope = $definition->getScope(); // returns "prototype"In this example, we create a new service definition for the "MyService" class and set the scope to "prototype". We then use the `getScope` method to retrieve the scope of the service definition and store it in the `$serviceScope` variable. This method is part of the Symfony DependencyInjection Component.