You are here

public function FarmEntityBundlePluginHandler::getFieldDefinitions in farmOS 2.x

File

modules/core/entity/src/BundlePlugin/FarmEntityBundlePluginHandler.php, line 42

Class

FarmEntityBundlePluginHandler
Extends BundlePluginHandler to invoke hook_farm_entity_bundle_field_info().

Namespace

Drupal\farm_entity\BundlePlugin

Code

public function getFieldDefinitions($bundle) {

  // Allow modules to add definitions.
  $definitions = \Drupal::moduleHandler()
    ->invokeAll('farm_entity_bundle_field_info', [
    $this->entityType,
    $bundle,
  ]);

  // Ensure the presence of required keys which aren't set by the plugin.
  // This is copied directly from the parent method for consistency.
  foreach ($definitions as $field_name => $definition) {
    $definition
      ->setName($field_name);
    $definition
      ->setTargetEntityTypeId($this->entityType
      ->id());
    $definition
      ->setTargetBundle($bundle);
    $definitions[$field_name] = $definition;
  }

  // Get definitions from the parent method.
  $definitions += parent::getFieldDefinitions($bundle);
  return $definitions;
}