Rename removeComponent method to hideComponent in EntityDisplayBase for clarity

Created on 22 July 2024, 3 months ago
Updated 25 July 2024, 3 months ago

Problem/Motivation

EntityDisplayBase uses the method removeComponent as a way to hide components from it's display, this is confusing language as "remove" is usually interpreted as a deletion, we've seen this confusion in 📌 Determine which core config entity methods should be config actions Fixed

Proposed resolution

  • Create new method from removeComponent to hideComponent
  • Update removeComponent to call new method and trigger deprecation notice
  • Update referencing code to new method
  • Update Tests
  • Change record?
✨ Feature request
Status

Active

Version

11.0 🔥

Component
Entity  →

Last updated about 8 hours ago

  • Maintained by
  • 🇬🇧United Kingdom @catch
  • 🇨🇭Switzerland @berdir
  • 🇩🇪Germany @hchonov
Created by

🇨🇦Canada b_sharpe

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @b_sharpe
  • Assigned to annmarysruthy
  • 🇮🇳India amanbtr72

    Not only "EntityDisplayBase" uses the method many other files also contains "removeComponent"

    Need to change there also.

    Are we going to do this with the this issue or need to create another issue tickets

    Search "removeComponent" (67 hits in 44 files of 30291 searched) [Normal]
      D:\wamp64\www\drupal10\core\lib\Drupal\Core\Entity\Display\EntityDisplayInterface.php (1 hit)
    	Line  67:   public function removeComponent($name);
      D:\wamp64\www\drupal10\core\lib\Drupal\Core\Entity\EntityDisplayBase.php (5 hits)
    	Line 184:             $this->removeComponent($name);
    	Line 200:             $this->removeComponent($name);
    	Line 376:   public function removeComponent($name) {
    	Line 450:         $this->removeComponent($entity->getName());
    	Line 480:             $this->removeComponent($name);
      D:\wamp64\www\drupal10\core\lib\Drupal\Core\Entity\EntityDisplayRepositoryInterface.php (1 hit)
    	Line 135:    *   ->removeComponent('field_image')
      D:\wamp64\www\drupal10\core\lib\Drupal\Core\Entity\EntityViewBuilder.php (1 hit)
    	Line 513:           $display->removeComponent($name);
      D:\wamp64\www\drupal10\core\modules\comment\comment.module (1 hit)
    	Line 759:           $view_display->removeComponent($field);
      D:\wamp64\www\drupal10\core\modules\comment\src\Tests\CommentTestTrait.php (2 hits)
    	Line 104:           $display->removeComponent($field_name)->save();
    	Line 122:           $display->removeComponent($field_name)->save();
      D:\wamp64\www\drupal10\core\modules\comment\tests\src\Functional\CommentDisplayConfigurableTest.php (2 hits)
    	Line 79:     $display->removeComponent('uid')
    	Line 80:       ->removeComponent('created')
      D:\wamp64\www\drupal10\core\modules\comment\tests\src\Functional\CommentLinksTest.php (2 hits)
    	Line 139:       ->removeComponent('links')
    	Line 152:       ->removeComponent('links')
      D:\wamp64\www\drupal10\core\modules\comment\tests\src\Functional\CommentTestBase.php (1 hit)
    	Line 256:       $form_display->removeComponent('subject');
      D:\wamp64\www\drupal10\core\modules\config\tests\src\Functional\ConfigExportImportUITest.php (1 hit)
    	Line 140:       ->removeComponent($this->fieldName)
      D:\wamp64\www\drupal10\core\modules\contact\tests\src\Functional\ContactSitewideTest.php (1 hit)
    	Line 495:       ->removeComponent('mail')
      D:\wamp64\www\drupal10\core\modules\field\tests\src\Functional\FormTest.php (1 hit)
    	Line 654:       ->removeComponent($this->field->getName())
      D:\wamp64\www\drupal10\core\modules\field\tests\src\Kernel\FieldAttachOtherTest.php (3 hits)
    	Line  91:     $display->removeComponent($this->fieldTestData->field_name);
    	Line 285:         $display->removeComponent($name);
    	Line 379:         $display->removeComponent($name);
      D:\wamp64\www\drupal10\core\modules\field_ui\src\Form\EntityDisplayFormBase.php (3 hits)
    	Line 310:       $this->entity->removeComponent($field_name);
    	Line 610:         $entity->removeComponent($field_name);
    	Line 638:         $entity->removeComponent($name);
      D:\wamp64\www\drupal10\core\modules\field_ui\tests\src\Functional\ManageFieldsFunctionalTest.php (1 hit)
    	Line 106:       ->removeComponent($field_name)
      D:\wamp64\www\drupal10\core\modules\field_ui\tests\src\Kernel\EntityDisplayTest.php (3 hits)
    	Line 108:     $display->removeComponent('component_3');
    	Line 192:     $display->removeComponent('display_extra_field');
    	Line 221:     $display->removeComponent('display_extra_field');
      D:\wamp64\www\drupal10\core\modules\field_ui\tests\src\Kernel\EntityFormDisplayTest.php (1 hit)
    	Line 306:     $form_display->removeComponent('langcode');
      D:\wamp64\www\drupal10\core\modules\image\tests\src\Functional\ImageAdminStylesTest.php (1 hit)
    	Line 501:       ->removeComponent($field_name)
      D:\wamp64\www\drupal10\core\modules\layout_builder\src\Controller\MoveBlockController.php (1 hit)
    	Line 69:     $section->removeComponent($block_uuid);
      D:\wamp64\www\drupal10\core\modules\layout_builder\src\Entity\LayoutBuilderEntityViewDisplay.php (1 hit)
    	Line 412:             $section->removeComponent($uuid);
      D:\wamp64\www\drupal10\core\modules\layout_builder\src\Form\MoveBlockForm.php (1 hit)
    	Line 258:       $original_section->removeComponent($this->uuid);
      D:\wamp64\www\drupal10\core\modules\layout_builder\src\Form\RemoveBlockForm.php (1 hit)
    	Line 70:     $section_storage->getSection($this->delta)->removeComponent($this->uuid);
      D:\wamp64\www\drupal10\core\modules\layout_builder\src\Section.php (1 hit)
    	Line 223:   public function removeComponent($uuid) {
      D:\wamp64\www\drupal10\core\modules\layout_builder\tests\src\Unit\SectionTest.php (3 hits)
    	Line  83:    * @covers ::removeComponent
    	Line  86:   public function testRemoveComponent(): void {
    	Line  92:     $this->section->removeComponent('10000000-0000-1000-a000-000000000000');
      D:\wamp64\www\drupal10\core\modules\media\src\MediaSourceInterface.php (4 hits)
    	Line 150:    * \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent() to
    	Line 159:    * @see \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent()
    	Line 168:    * \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent() to
    	Line 177:    * @see \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent()
      D:\wamp64\www\drupal10\core\modules\media\src\MediaTypeForm.php (1 hit)
    	Line 377:           $display->removeComponent($name);
      D:\wamp64\www\drupal10\core\modules\media\src\Plugin\media\Source\OEmbed.php (1 hit)
    	Line 539:     $display->removeComponent('name');
      D:\wamp64\www\drupal10\core\modules\media\tests\modules\media_test_source\src\Plugin\media\Source\TestWithHiddenSourceField.php (2 hits)
    	Line 26:     $display->removeComponent($this->getSourceFieldDefinition($type)->getName());
    	Line 33:     $display->removeComponent($this->getSourceFieldDefinition($type)->getName());
      D:\wamp64\www\drupal10\core\modules\media\tests\src\Functional\FieldFormatter\OEmbedFormatterTest.php (1 hit)
    	Line 209:     ])->removeComponent('thumbnail')
      D:\wamp64\www\drupal10\core\modules\media\tests\src\FunctionalJavascript\MediaSourceTestBase.php (1 hit)
    	Line 105:       $entity_form_display->removeComponent($field_name)->save();
      D:\wamp64\www\drupal10\core\modules\media\tests\src\Kernel\MediaEmbedFilterTestBase.php (3 hits)
    	Line 114:     ])->removeComponent('thumbnail')
    	Line 115:       ->removeComponent('created')
    	Line 116:       ->removeComponent('uid')
      D:\wamp64\www\drupal10\core\modules\media_library\media_library.module (2 hits)
    	Line 412:     $display->removeComponent($name);
    	Line 459:     $display->removeComponent($name);
      D:\wamp64\www\drupal10\core\modules\migrate\src\Plugin\migrate\destination\ComponentEntityDisplayBase.php (1 hit)
    	Line  79:       $entity->removeComponent($values['field_name']);
      D:\wamp64\www\drupal10\core\modules\node\tests\src\Functional\NodeEditFormTest.php (1 hit)
    	Line 215:     $form_display->removeComponent('uid')->save();
      D:\wamp64\www\drupal10\core\modules\node\tests\src\Functional\NodeLinksTest.php (1 hit)
    	Line 45:       ->removeComponent('links')
      D:\wamp64\www\drupal10\core\modules\node\tests\src\Functional\PagePreviewTest.php (1 hit)
    	Line 238:       ->removeComponent('body')
      D:\wamp64\www\drupal10\core\modules\node\tests\src\Functional\Views\NodeFieldFilterTest.php (1 hit)
    	Line 109:       ->removeComponent('links')
      D:\wamp64\www\drupal10\core\modules\path\tests\src\Functional\PathMediaFormTest.php (1 hit)
    	Line 63:       ->removeComponent('path')
      D:\wamp64\www\drupal10\core\modules\path\tests\src\Functional\PathNodeFormTest.php (1 hit)
    	Line 54:       ->removeComponent('path')
      D:\wamp64\www\drupal10\core\modules\system\tests\src\Functional\Entity\EntityFormTest.php (1 hit)
    	Line  93:     ])->removeComponent('field_test_text')->save();
      D:\wamp64\www\drupal10\core\modules\taxonomy\tests\src\Functional\Views\TermDisplayConfigurableTest.php (1 hit)
    	Line 79:     $display->removeComponent('name')->save();
      D:\wamp64\www\drupal10\core\modules\views\tests\src\Kernel\Handler\FieldRenderedEntityTest.php (1 hit)
    	Line 121:     $display->removeComponent('test_field')
      D:\wamp64\www\drupal10\core\tests\Drupal\KernelTests\Core\Entity\EntityDisplayFormBaseTest.php (2 hits)
    	Line  41:     $entity->removeComponent('new_field_mismatch_type_visible')
    	Line  80:     $entity->removeComponent('field_start_visible_change_region')
      D:\wamp64\www\drupal10\core\tests\Drupal\KernelTests\Core\Entity\FieldWidgetConstraintValidatorTest.php (1 hit)
    	Line  84:       $display->removeComponent($hidden_field);
    
  • 🇺🇸United States phenaproxima Massachusetts

    Yeah, but we can't just rename the interface method, as that would break backwards compatibility.

    The thing we need to do here is add a new interface method and deprecate the old one, assuming that's allowed under the backwards compatibility policy.

  • Pipeline finished with Canceled
    3 months ago
    Total: 234s
    #233125
  • Pipeline finished with Failed
    3 months ago
    #233145
  • Issue was unassigned.
  • Pipeline finished with Failed
    3 months ago
    Total: 1387s
    #233566
  • 🇨🇦Canada b_sharpe

    Yeah, but we can't just rename the interface method, as that would break backwards compatibility.

    Updated summary to be more clear of the original intent here.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 7961s
    #284992
Production build 0.71.5 2024