Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
It would be nice to have a command that could list available container services. We can filter these much like vget does, and also sort them.
Should be pretty simple to do.
Comment | File | Size | Author |
---|---|---|---|
#23 | devel-list-container-services-ui-1950930-23.patch | 3.67 KB | willzyx |
#20 | 1950930-20.patch | 1.81 KB | damiankloip |
#18 | 1950930-18.patch | 1.81 KB | damiankloip |
#18 | interdiff-1950930-18.txt | 515 bytes | damiankloip |
#15 | 1950930-15.patch | 1.81 KB | damiankloip |
Comments
Comment #1
damiankloip CreditAttribution: damiankloip commentedComment #2
damiankloip CreditAttribution: damiankloip commentedIf this idea flies, I can write some tests.
Btw, using the output engine stuff is awesome!
Comment #3
moshe weitzman CreditAttribution: moshe weitzman commentedIs there a reason why they should ever be unsorted?
I put the event listing command in devel, and i think this is similar. So, moving to devel project. I know that some folks won't like this decision but drush can't carry all the stuff that folks want to do with drupal. Devel exists for a reason.
Comment #4
damiankloip CreditAttribution: damiankloip commentedI guess there is no reason why you would want that unsorted, I can remove that option.
Also, I think moving this to devel is a great idea. I'm all for it. I didn't actually think about that. Agree that everything can't live in the drush codebase.
Comment #5
damiankloip CreditAttribution: damiankloip commentedComment #6
salvisI'd love to see this in the Devel GUI, too.
Comment #7
dawehnerMaybe we should also check for an empty container, for some reasons? No idea, though I can't imagine how there could be no services, if there is a container and a full bootstrap.
Just wondering whether there are some thoughts about dependency injection in drush :)
Comment #8
damiankloip CreditAttribution: damiankloip commentedOk, I have rerolled for devel instead of core drush, removed the sort option, and added a check for the container.
Comment #9
damiankloip CreditAttribution: damiankloip commentedSorry, wrong patch.
Comment #10
damiankloip CreditAttribution: damiankloip commentedDo we want to use
if($container = Drupal::getContainer()) {...}
syntax instead? I don't mind, I guess it's all down to code style preferences.Comment #11
dawehnerI don't mind either, it's just that these checks feels unneeded. Shouldn't we assume that if a full boostrap of drupal is done, it should work everything as expected?
Should we return something special, if there is no services with a certain prefix, like trigger an error?
Comment #12
damiankloip CreditAttribution: damiankloip commentedHow about we just move the check for services below the prefix matching?
I feel we should leave the container check in, if someone has really broken their D8 installation this may help them at some point? If not, I'm happy to remove this too.
Comment #13
damiankloip CreditAttribution: damiankloip commentedOops, soory. a real patch is usually helpful.
Comment #14
dawehnerPHP is so cool, that it doesn't need to return the sorted array if you sort :)
Comment #15
damiankloip CreditAttribution: damiankloip commentedThanks dawehner! that will not return us any services :)
Comment #16
dawehnerAwesome!
Comment #17
dawehner#15: 1950930-15.patch queued for re-testing.
Comment #18
damiankloip CreditAttribution: damiankloip commented@amateescu spotted an extra space in the format description. Minor :)
Comment #19
moshe weitzman CreditAttribution: moshe weitzman commentedSome command like this (e.g. core-config) will provide a choice menu when no argument is passed. The user then picks the service they care about and detail is shown. IMO thats better UX.
Is it really an error if no services are found. Instead use drush_log('No services found', 'ok').
Comment #20
damiankloip CreditAttribution: damiankloip commentedMade that change for drush_log. We talked about this on IRC, and think the actual implementation is good.
Comment #21
pcambraCommitted the drush part in #20 to the D8 branch, it'd be great to have an UI for this as well.
Comment #22
moshe weitzman CreditAttribution: moshe weitzman commentedComment #23
willzyx CreditAttribution: willzyx commentedFirst try for the UI part
Comment #24
jibranPossibly related issue #2419235: phpstorm-metadata should only dump all services objects..
Comment #25
willzyx CreditAttribution: willzyx commented@jibran maybe I'm wrong but I do not think the issues are related.. Also the drush part of this issue has already been committed (see 9f4c384); that is left to do is to create the UI
Comment #26
lussolucaWebprofiler provides an UI for container services: We can try to extract more info or we can close this issue.
Comment #27
moshe weitzman CreditAttribution: moshe weitzman at Acquia commentedOK, lets close this. Feature requests can be new follow-up issues.