You are here

public function Material::buildFieldDefinitions in farmOS 2.x

Same name in this branch
  1. 2.x modules/asset/material/src/Plugin/Asset/AssetType/Material.php \Drupal\farm_material\Plugin\Asset\AssetType\Material::buildFieldDefinitions()
  2. 2.x modules/quantity/material/src/Plugin/Quantity/QuantityType/Material.php \Drupal\farm_quantity_material\Plugin\Quantity\QuantityType\Material::buildFieldDefinitions()

Overrides AssetTypeBase::buildFieldDefinitions

File

modules/asset/material/src/Plugin/Asset/AssetType/Material.php, line 20

Class

Material
Provides the material asset type.

Namespace

Drupal\farm_material\Plugin\Asset\AssetType

Code

public function buildFieldDefinitions() {
  $fields = parent::buildFieldDefinitions();
  $field_info = [
    'material_type' => [
      'type' => 'entity_reference',
      'label' => $this
        ->t('Material type'),
      'description' => $this
        ->t("Enter the type of material."),
      'target_type' => 'taxonomy_term',
      'target_bundle' => 'material_type',
      'auto_create' => TRUE,
      'required' => TRUE,
      'weight' => [
        'form' => -90,
        'view' => -50,
      ],
    ],
  ];
  foreach ($field_info as $name => $info) {
    $fields[$name] = $this->farmFieldFactory
      ->bundleFieldDefinition($info);
  }
  return $fields;
}