QueryFactory is deprecated. We should use EntityTypeManager
Ref. https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21...
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | interdiff.txt | 3.19 KB | mile23 |
| #6 | 2897889_6.patch | 4.45 KB | mile23 |
| #4 | 2897889-review.patch | 2.3 KB | chaitanya17 |
| #2 | 2897889-patch.patch | 2.31 KB | chaitanya17 |
Comments
Comment #2
chaitanya17 commentedPlease check attached working patch.
Comment #3
mile23Nice catch. Good to get rid of deprecated code.
Just a few things:
What we end up doing here is getting the entity type storage for 'robot.'
So we shouldn't get the entity type manager service, we should get the storage object.
Also, when we do that, we want to deal with interfaces instead of concrete class types. If you look at
getStorage(), it returns\Drupal\Core\Entity\EntityStorageInterfacewhich is how we want to type hint our local variable, and the argument to__construct().I looked and I couldn't find any tests of whether
exists()is meaningful in our form.We need two more tests, inside of
testConfigEntityExample():1) Try to re-submit Robby robot with a duplicate machine name. That should result in an error message based on
exists(). (If the form is set up incorrectly, we'll get an exception complaining that it's a duplicate ID.)2) Try to submit a robot with the machine name 'custom' so we can make sure our form API regex catches it.
Comment #4
chaitanya17 commentedHi @Mile23,
Thanks for reviewing patch. I have implemented points 1. Please check attached patch.
For Point 2.
In function
testConfigEntityExampleComment #5
mile23In #3.2 I'm talking about this:
That's the machine name. Our exists() method complains if the machine name is the word 'custom'. We don't have a test for it, though.
Also, an interdiff makes it much easier to see what changes you made since the last patch. https://www.drupal.org/documentation/git/interdiff
Thanks.
Comment #6
mile23Fixed the failing test and added the tests mentioned in #3.2.
This fixes some of the technical debt we see when we test against core 8.6.x in #2952984-19: Add example drupalci.yml file to un-suppress deprecations
Comment #8
mile23Committed and pushed. Thanks!