devel_generate_fields.module

Test module for field population.

File

devel_generate/tests/modules/devel_generate_fields/devel_generate_fields.module

View source
<?php


/**
 * @file
 * Test module for field population.
 */
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Implements hook_entity_base_field_info_alter().
 */
function devel_generate_fields_entity_base_field_info_alter(array &$fields, EntityTypeInterface $entity_type) : void {
    if (in_array($entity_type->id(), [
        'node',
        'media',
    ])) {
        $fields['phish'] = BaseFieldDefinition::create('string')->setName('phish')
            ->setLabel(new TranslatableMarkup('Phish music'));
    }
}

Functions

Title Deprecated Summary
devel_generate_fields_entity_base_field_info_alter Implements hook_entity_base_field_info_alter().