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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

akshay_d created an issue. See original summary.

akshay_d’s picture

Status: Active » Needs review
FileSize
1.23 KB

deprecated methods removed, please review

akshay_d’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 2: deprecated_method_removed-3031519-2.patch, failed testing. View results

akshay_d’s picture

Status: Needs work » Needs review
FileSize
1.52 KB

updated deprecated method

Status: Needs review » Needs work

The last submitted patch, 5: removed_deprecated_method-3031519-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joelpittet’s picture

There is a failure in the code but here's one hint:

+++ b/modules/ctools_entity_mask/tests/src/Kernel/EntityMaskTest.php
@@ -86,7 +87,7 @@ class EntityMaskTest extends KernelTestBase {
-    $display = entity_get_form_display('fake_block_content', 'basic', 'default');
+    $display = \Drupal::service('entity_display.repository')->getViewDisplay('fake_block_content', 'basic', 'default');

This is getting the form display not the view display?

Thanks for trying to fix these!

bhanuprakashnani’s picture

Assigned: Unassigned » bhanuprakashnani
bhanuprakashnani’s picture

Status: Needs work » Needs review
FileSize
1.23 KB

I 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.

Status: Needs review » Needs work

The last submitted patch, 9: 3031519-9.patch, failed testing. View results

joelpittet’s picture

Thank you again, the failed tests will need to be resolved before I can commit this

bhanuprakashnani’s picture

Status: Needs work » Needs review
FileSize
1.52 KB

Sorry for the mistake. I forgot to include the EntityTypeManagerManager

Status: Needs review » Needs work

The last submitted patch, 12: 3031519-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bhanuprakashnani’s picture

Status: Needs work » Needs review
FileSize
1.58 KB

Added the entityformdisplayinterface.

Status: Needs review » Needs work

The last submitted patch, 14: 3031519-14.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bhanuprakashnani’s picture

I 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.

andrey.troeglazov’s picture

andrey.troeglazov’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 17: ctools_deprecated_functions-3031519-17.patch, failed testing. View results

andrey.troeglazov’s picture

Status: Needs work » Needs review
FileSize
1.27 KB

Status: Needs review » Needs work

The last submitted patch, 20: ctools_deprecated_functions-3031519-20.patch, failed testing. View results

bkhandruk’s picture

Hi!

This should work.

andrey.troeglazov’s picture

Yes this way it will work, but I thought it should be already created somewhere before.

bkhandruk’s picture

@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

andrey.troeglazov’s picture

Status: Needs review » Reviewed & tested by the community

Yes 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.

andrey.troeglazov’s picture

/summon @joelpittet :)

joelpittet’s picture

Status: Reviewed & tested by the community » Needs work

I'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.

joelpittet’s picture

Status: Needs work » Needs review
FileSize
1.53 KB

This should work because it's expecting the result to assert isNew() == TRUE on the $display.

joelpittet’s picture

I 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)

joelpittet’s picture

Status: Needs review » Fixed

I wonder why this started failing in 8.7 recently but I've committed it to the dev branch. Thanks for all your help!

Status: Fixed » Closed (fixed)

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