You are here

public function Equipment::buildFieldDefinitions in farmOS 2.x

Overrides AssetTypeBase::buildFieldDefinitions

File

modules/asset/equipment/src/Plugin/Asset/AssetType/Equipment.php, line 20

Class

Equipment
Provides the equipment asset type.

Namespace

Drupal\farm_equipment\Plugin\Asset\AssetType

Code

public function buildFieldDefinitions() {
  $fields = parent::buildFieldDefinitions();
  $field_info = [
    'manufacturer' => [
      'type' => 'string',
      'label' => $this
        ->t('Manufacturer'),
      'weight' => [
        'form' => -20,
        'view' => -50,
      ],
    ],
    'model' => [
      'type' => 'string',
      'label' => $this
        ->t('Model'),
      'weight' => [
        'form' => -15,
        'view' => -40,
      ],
    ],
    'serial_number' => [
      'type' => 'string',
      'label' => $this
        ->t('Serial number'),
      'weight' => [
        'form' => -10,
        'view' => -30,
      ],
    ],
  ];
  foreach ($field_info as $name => $info) {
    $fields[$name] = $this->farmFieldFactory
      ->bundleFieldDefinition($info);
  }
  return $fields;
}