You are here

farm_entity_contrib_test.module in farmOS 2.x

File

modules/core/entity/tests/modules/farm_entity_contrib_test/farm_entity_contrib_test.module
View source
<?php

/**
 * @file
 * Contains farm_entity_contrib_test.module.
 */
use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Implements hook_farm_entity_bundle_field_info().
 */
function farm_entity_contrib_test_farm_entity_bundle_field_info(EntityTypeInterface $entity_type, string $bundle) {
  $fields = [];

  // Add a new bundle field to test logs.
  if ($entity_type
    ->id() == 'log' && in_array($bundle, [
    'test',
  ])) {
    $options = [
      'type' => 'string',
      'label' => t('Test hook bundle field'),
    ];
    $fields['test_contrib_hook_bundle_field'] = \Drupal::service('farm_field.factory')
      ->bundleFieldDefinition($options);
  }
  return $fields;
}