You are here

public function UIOverrideProvider::referenceViewFieldsOverride in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_entity/src/UIOverrideProvider.php \Drupal\bibcite_entity\UIOverrideProvider::referenceViewFieldsOverride()

Override fields attributes for reference view.

Parameters

array $element: Element render array.

string $bundle_id: Entity bundle identifier.

File

modules/bibcite_entity/src/UIOverrideProvider.php, line 84

Class

UIOverrideProvider
Collection of hardcoded overrides for reference form and view.

Namespace

Drupal\bibcite_entity

Code

public function referenceViewFieldsOverride(array &$element, $bundle_id) {

  /** @var \Drupal\bibcite_entity\Entity\ReferenceTypeInterface $bundle */
  if (($bundle = $this->typeStorage
    ->load($bundle_id)) && $bundle
    ->isRequiredOverride()) {
    foreach ($bundle
      ->getFields() as $field_name => $field_config) {
      if (isset($element[$field_name])) {
        if (!empty($field_config['label'])) {
          $element[$field_name]['#title'] = $field_config['label'];
        }
      }
    }
  }
}