One of the remaining legitimate usages of the deprecated \Drupal::getContainer() method is to call ContainerInterface::has().
Let's provide a method for that on \Drupal, as suggested in #1376122-38: Stream wrappers of parent site are leaking into all tests

Comments

tstoeckler’s picture

I think since we have \Drupal::service() maybe \Drupal::hasService() would be more consistent. Note that we also have non-container stuff on \Drupal, i.e. \Drupal::VERSION and that's probably going to become more.

tim.plunkett’s picture

Status: Active » Needs review
StatusFileSize
new5.91 KB

Good idea!

tim.plunkett’s picture

Title: Provide a \Drupal::has() method » Provide a \Drupal::hasService() method
jibran’s picture

Status: Needs review » Reviewed & tested by the community

\Issue::hasPatch() nice clean up so RTBC.

sun’s picture

Status: Reviewed & tested by the community » Needs review
Related issues: +#2084521: Improve error handling of \Drupal class

This duplicates #2084521: Improve error handling of \Drupal class to a good extent...

sun’s picture

tim.plunkett’s picture

It doesn't duplicate a single line of that patch. It does conflict with it, sure.

Status: Needs review » Needs work

The last submitted patch, 2: container-has-2182439-2.patch, failed testing.

tstoeckler’s picture

Status: Needs work » Needs review

2: container-has-2182439-2.patch queued for re-testing.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

catch’s picture

Title: Provide a \Drupal::hasService() method » Change notice: Provide a \Drupal::hasService() method
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

Committed/pushed to 8.x, thanks!

Could use a change notice/update.

xjm’s picture

Issue tags: +Missing change record
tim.plunkett’s picture

Status: Active » Needs review
xjm’s picture

Title: Change notice: Provide a \Drupal::hasService() method » Provide a \Drupal::hasService() method
Status: Needs review » Fixed
Issue tags: -Needs change record, -Missing change record

I keep editing the issue out of habit. :)

Change record looks good; published. I searched for "getContainer" in the existing change records and it doesn't look like there's anything else to update.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.