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.
Problem/Motivation
entity_get_display() and entity_get_form_display() moved to EntityDisplayRepositoryInterface
Proposed resolution
Remove the deprecated methods According to #2835616
In modules/ctools_entity_mask/tests/src/Kernel/EntityMaskTest.php
Comments
Comment #2
akshay_ddeprecated methods removed, please review
Comment #3
akshay_dComment #5
akshay_dupdated deprecated method
Comment #7
joelpittetThere is a failure in the code but here's one hint:
This is getting the form display not the view display?
Thanks for trying to fix these!
Comment #8
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedComment #9
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedI have changed the getViewDisplay to getFormDisplay as the function entity_get_form_display is form-display function, not a view display one. Please review and let me know whether my step was correct or not. Would like to work on this issue if anything more required thank you.
Comment #11
joelpittetThank you again, the failed tests will need to be resolved before I can commit this
Comment #12
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedSorry for the mistake. I forgot to include the EntityTypeManagerManager
Comment #14
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedAdded the entityformdisplayinterface.
Comment #16
bhanuprakashnani CreditAttribution: bhanuprakashnani at Google Summer of Code commentedI am not able to get why am I getting errors when I have include
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\EntityTypeManagerManager;
It is throwin an error that an undefined function is being called. But the functions getFormDisplay and getViewDisplay are valid right. Can some one please tell me where am i going wrong. Thank you.
Comment #17
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commentedComment #18
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commentedComment #20
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commentedComment #22
bkhandruk CreditAttribution: bkhandruk commentedHi!
This should work.
Comment #23
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commentedYes this way it will work, but I thought it should be already created somewhere before.
Comment #24
bkhandruk CreditAttribution: bkhandruk commented@andrey.troeglazov
View/form configuration is not created by default for each entity type and bundle where view/form mode is available.
That's why we have this check and we create one if nothing is loaded.
Also the logs from testing patch #20 are pretty clear about the reason why it's failed.
https://www.drupal.org/pift-ci-job/1196548
Comment #25
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commentedYes I know, I mean entity_get_form_display tries to load display and if can't it creates a new one.
Now I see that EntityFormDisplay::load() only loads it and not creating. Thank you. RTBC from me.
Comment #26
andrey.troeglazov CreditAttribution: andrey.troeglazov at DrupalJedi commented/summon @joelpittet :)
Comment #27
joelpittetI'm looking at the creation like mentioned in #23, that doesn't seem the right place to create those, if the creation needs to happen it should happen before so we know the state going into the test, so in setUp() or elsewhere and not conditional.
Comment #28
joelpittetThis should work because it's expecting the result to assert isNew() == TRUE on the $display.
Comment #29
joelpittetI see where you're coming from @rocket.man on the patch so thank you for doing that! The test assertion is not needed if we know we're creating it but I think it's fine to have expectations that if we create it because it's not there then that should be enough for the test. (sorry hope that make sense, explaining is a bit fuzzy at the moment)
Comment #31
joelpittetI wonder why this started failing in 8.7 recently but I've committed it to the dev branch. Thanks for all your help!