You are here

public function NameItem::activeComponents in Name Field 8

Get a list of active components.

Return value

array Keyed array of active component labels.

File

src/Plugin/Field/FieldType/NameItem.php, line 176

Class

NameItem
Plugin implementation of the 'name' field type.

Namespace

Drupal\name\Plugin\Field\FieldType

Code

public function activeComponents() {
  $settings = $this
    ->getFieldDefinition()
    ->getSettings();
  $components = [];
  foreach (_name_translations() as $key => $label) {
    if (!empty($settings['components'][$key])) {
      $components[$key] = empty($settings['labels'][$key]) ? $label : $settings['labels'][$key];
    }
  }
  return $components;
}