comment_display_configurable_test.module

Same filename in other branches
  1. 10 core/modules/comment/tests/modules/comment_display_configurable_test/comment_display_configurable_test.module
  2. 11.x core/modules/comment/tests/modules/comment_display_configurable_test/comment_display_configurable_test.module

A module for testing making comment base fields' displays configurable.

File

core/modules/comment/tests/modules/comment_display_configurable_test/comment_display_configurable_test.module

View source
<?php


/**
 * @file
 * A module for testing making comment base fields' displays configurable.
 */
use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Implements hook_entity_base_field_info_alter().
 */
function comment_display_configurable_test_entity_base_field_info_alter(&$base_field_definitions, EntityTypeInterface $entity_type) {
    if ($entity_type->id() == 'comment') {
        foreach ([
            'created',
            'uid',
            'pid',
            'subject',
        ] as $field) {
            
            /** @var \Drupal\Core\Field\BaseFieldDefinition[] $base_field_definitions */
            $base_field_definitions[$field]->setDisplayConfigurable('view', TRUE);
        }
    }
}

/**
 * Implements hook_entity_type_build().
 */
function comment_display_configurable_test_entity_type_build(array &$entity_types) {
    // Allow skipping of extra preprocessing for configurable display.
    $entity_types['comment']->set('enable_base_field_custom_preprocess_skipping', TRUE);
}

Functions

Title Deprecated Summary
comment_display_configurable_test_entity_base_field_info_alter Implements hook_entity_base_field_info_alter().
comment_display_configurable_test_entity_type_build Implements hook_entity_type_build().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.