Q | A |
---|
Branch? | 7.3 |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Issues | - |
License | MIT |
Hello,
I improved the text descriptor and test for of the "--show-arguments" command in order to show in a service locator (arguments or a tagged iterator) and other iterator argument to display more information of the services in the arguments.
I moved information of arguments just after the main table because a lots of service could exist.
A fake class for a test :
<?phpdeclare(strict_types=1);namespaceApp\Service\Fake;usePsr\Container\ContainerInterface;useSymfony\Component\DependencyInjection\Attribute\AutowireIterator;useSymfony\Component\DependencyInjection\Attribute\AutowireLocator;readonlyclass ServiceWithTaggedIteratorAndServiceLocatorInjection{publicfunction__construct(publicarray$simpleIterator,public\Closure$serviceLocatorAsClosure, #[AutowireLocator(services: ['one' => One::class,'two' => Two::class, ])]publicContainerInterface$autowireLocator, #[AutowireLocator('app.fake_tag')]publicContainerInterface$autowireLocatorWithStringTag, #[AutowireIterator('app.fake_tag')]publicContainerInterface$taggedLocator,publicContainerInterface$servicesTagged,publicServiceHasLocator$serviceLocator,publicContainerInterface$containerServiceLocator,publicContainerInterface$containerServiceLocatorNotAutoconfigure,publicstring$abstractArg,publicFooEnum$enumArg,publicarray$iteratorArgument, ) { }}
Its yaml services configuration :
services:_defaults:autowire:trueautoconfigure:trueApp\:resource:'../src/'exclude: -'../src/DependencyInjection/' -'../src/Entity/' -'../src/Kernel.php'App\Service\Fake\One:tags:[{name: 'app.fake_tag'}, {name: 'app.fake_tag_2'}]App\Service\Fake\Two:tags:[{name: 'app.fake_tag'}, {name: 'app.fake_tag_2'}]App\Service\Fake\Three:tags:[{name: 'app.fake_tag'}, {name: 'app.fake_tag_2'}]App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection:arguments:$containerServiceLocator:'@my.locator'$simpleIterator:['@App\Service\Fake\One', '@App\Service\Fake\Two']$serviceLocatorAsClosure:!service_locatorApp\Service\Fake\One:'@App\Service\Fake\One'App\Service\Fake\Two:'@App\Service\Fake\Two'$taggedLocator:!tagged_locator {tag: 'app.fake_tag_2'}$servicesTagged:!tagged_iterator {tag: 'app.fake_tag'}$serviceLocator:'@App\Service\Fake\ServiceHasLocator'# Not expanded, it is a service which has a locator in its own context$containerServiceLocatorNotAutoconfigure:'@my.locator_not_autoconfigure'$abstractArg:!abstract 'should be defined by Pass'$enumArg:!php/enum App\Service\Fake\FooEnum::ONE$iteratorArgument: -'@App\Service\Fake\One' -'@App\Service\Fake\Two'my.locator:# A classical locatorclass:Symfony\Component\DependencyInjection\ServiceLocatorarguments: -router:'@router'request_stack:'@request_stack'http_kernel:'@http_kernel'session:'@session'parameter_bag:'@parameter_bag'contact_email:"mail@contact.com"mailerAsClosure:!service_closure '@mailer'my.locator_not_autoconfigure:autoconfigure:falseclass:Symfony\Component\DependencyInjection\ServiceLocatorarguments: -router:'@router'request_stack:'@request_stack'http_kernel:'@http_kernel'session:'@session'parameter_bag:'@parameter_bag'tags:[ 'container.service_locator' ]
Before :
php bin/console deb:cont"ServiceWithTaggedIteratorAndServiceLocatorInjection" --show-argumentsInformationfor Service"App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection"============================================================================================== ---------------- ---------------------------------------------------------------------- Option Value ---------------- ---------------------------------------------------------------------- Service ID App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection Class App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection Tags - Public no Synthetic no Lazy no Shared yes Abstract no Autowired yes Autoconfigured yes Arguments Array (2 element(s)) Service(.service_locator.BU3KPRp) Service(.service_locator.oF5goiR) Service(.service_locator.AdwCYyt) Service(.service_locator.idLRJzM) Tagged Iteratorfor"app.fake_tag" Service(App\Service\Fake\ServiceHasLocator) Service(my.locator) Service(my.locator_not_autoconfigure) Abstract argument (should be defined by Pass) App\Service\Fake\FooEnum::ONE Array (2 element(s)) Usages none ---------------- ----------------------------------------------------------------------
After :
php bin/console deb:cont"ServiceWithTaggedIteratorAndServiceLocatorInjection" --show-argumentsInformationfor Service"App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection"============================================================================================== ---------------- ---------------------------------------------------------------------- Option Value ---------------- ---------------------------------------------------------------------- Service ID App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection Class App\Service\Fake\ServiceWithTaggedIteratorAndServiceLocatorInjection Tags - Public no Synthetic no Lazy no Shared yes Abstract no Autowired yes Autoconfigured yes Usages none ---------------- ---------------------------------------------------------------------- +----+---------------------------- Arguments --------+------------------------+|# | Service | Argument(s) |+----+-----------------------------------------------+------------------------+| 1| Service locator (7 element(s))| router.default|||| request_stack|||| http_kernel|||| session|||| parameter_bag|||| ["mail@contact.com"]|||| mailer.mailer|+----+-----------------------------------------------+------------------------+| 2| Array (2 element(s))| -|+----+-----------------------------------------------+------------------------+| 3| Service locator (2 element(s))| App\Service\Fake\One|||| App\Service\Fake\Two|+----+-----------------------------------------------+------------------------+| 4| Service locator (2 element(s))| App\Service\Fake\One|||| App\Service\Fake\Two|+----+-----------------------------------------------+------------------------+| 5| Service locator (3 element(s))| App\Service\Fake\Three|||| App\Service\Fake\Two|||| App\Service\Fake\One|+----+-----------------------------------------------+------------------------+| 6| Service locator (3 element(s))| App\Service\Fake\Two|||| App\Service\Fake\Three|||| App\Service\Fake\One|+----+-----------------------------------------------+------------------------+| 7| Tagged Iteratorfor"app.fake_tag"| App\Service\Fake\One|||| App\Service\Fake\Three|||| App\Service\Fake\Two|+----+-----------------------------------------------+------------------------+| 8| Service(App\Service\Fake\ServiceHasLocator)| -|+----+-----------------------------------------------+------------------------+| 9| Service locator (5 element(s))| router.default|||| request_stack|||| http_kernel|||| session|||| parameter_bag|+----+-----------------------------------------------+------------------------+| 10| Abstract argument (should be defined by Pass)| -|+----+-----------------------------------------------+------------------------+| 11| App\Service\Fake\FooEnum::ONE| -|+----+-----------------------------------------------+------------------------+| 12| Array (2 element(s))| -|+----+-----------------------------------------------+------------------------+
I try to cover any sort of argument with the use of a locator into a service, but it could be useful to me if you have more cases to test (maybe some type, some kind of Definition or anything could be useful).
Thanks a lot :)
Uh oh!
There was an error while loading.Please reload this page.
Hello,
I improved the text descriptor and test for of the "--show-arguments" command in order to show in a service locator (arguments or a tagged iterator) and other iterator argument to display more information of the services in the arguments.
I moved information of arguments just after the main table because a lots of service could exist.
A fake class for a test :
Its yaml services configuration :
Before :
After :
I try to cover any sort of argument with the use of a locator into a service, but it could be useful to me if you have more cases to test (maybe some type, some kind of Definition or anything could be useful).
Thanks a lot :)