drupal_container() is deprecated, and all calls in the update module need to be replaced with Drupal::service(), except for where the module_handler service is requested, which needs to be replaced with Drupal::moduleHandler() (see #1957154: Replace calls to drupal_container()->get('module_handler') service with Drupal::moduleHandler())
This task a part of #2001206: Replace drupal_container() with Drupal::service()
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | drupal-remove-drupal-container-2014037-5.patch | 1.28 KB | hussainweb |
| #5 | drupal-remove-drupal-container-2014037-5.patch | 0 bytes | hussainweb |
| #2 | update-2014037-2.patch | 1.33 KB | kgoel |
Comments
Comment #1
kgoel commentedComment #2
kgoel commentedComment #3
dcam commented#2 looks good. I didn't find any more uses of drupal_container() in the update module.
Comment #4
webchickI think those should be Drupal::keyValue() instead.
Comment #5
hussainwebI am attaching a patch altered as per @webchick's recommendations.
I am a little confused about this, though. I read here that it it is preferred to use the service container to instantiate objects. As per the following block:
Calling Drupal::keyValue() seems to me to be a direct implementation detail. Of course, I checked the implementation and see that it just calls the container. I am not sure which is the better method. However, like I said, I am using Drupal::keyValue() as per @webchick's recommendation, but I would like someone to throw some light on this.
Comment #6
hussainwebSorry about the empty patch. Here is the correct one.
Comment #7
Bober commentedSeems good for me.
Comment #8
alexpottCommitted fc35679 and pushed to 8.x. Thanks!
Comment #9
kgoel commentedComment #10
alexpott@kgoel the move to closed(fixed) will happen automatically after 2 weeks without further comments.