You are here

public function GdprFieldConfigEntity::getField in General Data Protection Regulation 8

Same name and namespace in other branches
  1. 8.2 modules/gdpr_fields/src/Entity/GdprFieldConfigEntity.php \Drupal\gdpr_fields\Entity\GdprFieldConfigEntity::getField()
  2. 3.0.x modules/gdpr_fields/src/Entity/GdprFieldConfigEntity.php \Drupal\gdpr_fields\Entity\GdprFieldConfigEntity::getField()

Gets field metadata.

Parameters

string $bundle: Bundle.

string $field_name: Field name.

Return value

\Drupal\gdpr_fields\Entity\GdprField Field metadata.

1 call to GdprFieldConfigEntity::getField()
GdprFieldConfigEntity::getAllFields in modules/gdpr_fields/src/Entity/GdprFieldConfigEntity.php
Gets all GDPR field settings for this entity type.

File

modules/gdpr_fields/src/Entity/GdprFieldConfigEntity.php, line 85

Class

GdprFieldConfigEntity
Defines a GDPR Field configuration entity.

Namespace

Drupal\gdpr_fields\Entity

Code

public function getField($bundle, $field_name) {
  if (isset($this->bundles[$bundle][$field_name])) {
    $result = $this->bundles[$bundle][$field_name];
    if (empty($result['sars_filename'])) {
      $result['sars_filename'] = $this
        ->getFilename($bundle);
    }
    if (empty($result['entity_type_id'])) {
      $result['entity_type_id'] = $this
        ->id();
    }
    return new GdprField($result);
  }
  return new GdprField([
    'bundle' => $bundle,
    'name' => $field_name,
    'entity_type_id' => $this
      ->id(),
    'sars_filename' => $this
      ->getFilename($bundle),
  ]);
}