You are here

function farm_entity_contrib_test_farm_entity_bundle_field_info in farmOS 2.x

Implements hook_farm_entity_bundle_field_info().

File

modules/core/entity/tests/modules/farm_entity_contrib_test/farm_entity_contrib_test.module, line 13
Contains farm_entity_contrib_test.module.

Code

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;
}