drupal_container() is deprecated, and all calls in the simpletest 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 |
|---|---|---|---|
| #40 | simpletest-2014015-40.patch | 4.3 KB | berdir |
| #38 | simpletest-2014015-38.patch | 3.51 KB | kgoel |
| #36 | simpletest-2014015-36.patch | 3.51 KB | kgoel |
| #33 | simpletest-2014015-33.patch | 4.79 KB | kgoel |
| #33 | interdiff.txt | 569 bytes | kgoel |
Comments
Comment #1
dmitrii commentedComment #2
dmitrii commentedComment #3
andypostYou should always use internal container
$this->containerin testsComment #4
andyposttagged for rocketship
Comment #5
berdirThis is the thing that we're creating the internal container with, so that correctly uses Drupal, $this->container = $this->container isn't going to work very well ;), with the exception of the last one maybe about keyvalue.
I'd just say "Rebuild the container". You can't rebuild a method or function :)
Comment #6
dmitrii commentedComment #8
kgoel commentedComment #10
kgoel commentedComment #12
kgoel commentedComment #14
kgoel commentedAh, that was very stupid of me.
Comment #15
kgoel commentedComment #17
kgoel commentedand again....
Comment #19
dmitrii commented#6: drupal_container-2014015-6.patch queued for re-testing.
Comment #20
kgoel commentedI have looked into it a bit more and found that Drupal::getContainer is deprecated. My guess would be to use Drupal::$container but I want someone else to confirm before I post another silly patch.
Comment #21
berdirDrupal::getContainer() is correct, that's just a documentation bug :)
Comment #22
kgoel commented@Berdir - any idea why I am getting this fatal error - Undefined class constant 'getContainer' ?
Comment #23
berdirBecause it's a method, not a constant: \Drupal::getContainer();
Comment #24
kgoel commentedComment #26
kgoel commentedSo the patch failed and error seems to be here -
error message in review log is - 'The service definition "state" does not exist. Does this mean it needs a create method to inject keyvalue properly?
Comment #27
berdirHave a look at #1786490: Add caching to the state system, I had to fix that too there, the problem is that it's called too late. While you move it around, please change the container id it is checking from keyvalue to state, as that's what it is using.
Also, if you check in $this->container, you also want to call $this->container->get('state')->get().
Comment #28
berdirDouble post.
Comment #29
kgoel commentedComment #31
kgoel commentedComment #33
kgoel commentedHopefully this is it.
Comment #35
kgoel commented@Berdir - I have followed what you recommended under comment but it seems like same error I was getting before.
Comment #36
kgoel commentedComment #38
kgoel commentedComment #40
berdirThat's what I meant, let's try this. And yes, this is not a Novice issue :)
Comment #41
Crell commented#40: simpletest-2014015-40.patch queued for re-testing.
Comment #42
Crell commented#40 seems OK to me visually if the bot still approves. Mr. Roboto can CNW it if it wants.
Comment #43
webchickCommitted and pushed to 8.x. Thanks!
Comment #43.0
webchickadd link to related task