Skip to content
Snippets Groups Projects

Issues/3407912: Add hook_ENTITY_TYPE_view_mode_alter().

4 unresolved threads

Closes #3407912

Merge request reports

Members who can merge are allowed to add commits.
Approval is optional
Code Quality is loading
Test summary results are being parsed
Merge blocked: 1 check failed
Merge conflicts must be resolved.

Merge details

  • The source branch is 3008 commits behind the target branch.
  • 1 commit will be added to 11.x.
  • Source branch will not be deleted.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
308 308 $this->assertStringContainsString('Text in Spanish', (string) $rendered_reference_field_spanish);
309 309 }
310 310
311 /**
312 * Tests a view mode alter on an entity.
313 */
314 public function testHookEntityTypeViewModeAlter() {
  • 1697 1697 }
    1698 1698 }
    1699 1699
    1700 /**
    1701 * Change the view mode of a particular entity type that is being displayed.
    1702 *
    1703 * @param string $view_mode
    1704 * The view_mode that is to be used to display the entity.
    1705 * @param \Drupal\Core\Entity\EntityInterface $entity
    1706 * The entity that is being viewed.
    1707 *
    1708 * @ingroup entity_crud
    1709 */
    1710 function hook_ENTITY_TYPE_view_mode_alter(&$view_mode, \Drupal\Core\Entity\EntityInterface $entity) {
  • 294 294 }
    295 295 }
    296 296
    297 /**
    298 * Implements hook_ENTITY_TYPE_view_mode_alter().
    299 */
    300 function entity_test_entity_test_view_mode_alter(&$view_mode, EntityInterface $entity) {
  • added 1 commit

    • 8adbb4c2 - Addressed review comments, rephrase hook docblock

    Compare with previous version

  • 176 176 */
    177 177 protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
    178 178 // Allow modules to change the view mode.
    179 $this->moduleHandler()->alter('entity_view_mode', $view_mode, $entity);
    179 $entityType = $this->entityTypeId;
    180 $this->moduleHandler()->alter([$entityType . '_view_mode', 'entity_view_mode'], $view_mode, $entity);
    Please register or sign in to reply
    Loading