You are here

protected function NameFormatter::getLinkableTargets in Name Field 8

Find any linkable targets.

Return value

array An array of possible targets.

2 calls to NameFormatter::getLinkableTargets()
NameFormatter::settingsForm in src/Plugin/Field/FieldFormatter/NameFormatter.php
Returns a form to configure settings for the formatter.
NameFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/NameFormatter.php
Returns a short summary for the current formatter settings.

File

src/Plugin/Field/FieldFormatter/NameFormatter.php, line 331

Class

NameFormatter
Plugin implementation of the 'name' formatter.

Namespace

Drupal\name\Plugin\Field\FieldFormatter

Code

protected function getLinkableTargets() {
  $targets = [
    '_self' => $this
      ->t('Entity URL'),
  ];
  $bundle = $this->fieldDefinition
    ->getTargetBundle();
  $entity_type_id = $this->fieldDefinition
    ->getTargetEntityTypeId();
  $fields = $this->entityFieldManager
    ->getFieldDefinitions($entity_type_id, $bundle);
  foreach ($fields as $field) {
    if (!$field
      ->getFieldStorageDefinition()
      ->isBaseField()) {
      switch ($field
        ->getType()) {
        case 'entity_reference':
        case 'link':
          $targets[$field
            ->getName()] = $field
            ->getLabel();
          break;
      }
    }
  }
  return $targets;
}