You are here

function radioactivity_get_field_names in Radioactivity 4.0.x

Same name and namespace in other branches
  1. 8.3 radioactivity.module \radioactivity_get_field_names()

Get a list of Radioactivity field names.

1 call to radioactivity_get_field_names()
radioactivity_entity_load in ./radioactivity.module
Implements hook_entity_load().

File

./radioactivity.module, line 85
Provides a field type which can be used as a hotness metric.

Code

function radioactivity_get_field_names() {
  static $fields;
  if (is_array($fields)) {
    return $fields;
  }
  $fields = [];
  $entity_type_manager = Drupal::service('entity_type.manager');

  /** @var \Drupal\field\Entity\FieldStorageConfig[] $field_storage_configs */
  if (!($field_storage_configs = $entity_type_manager
    ->getStorage('field_storage_config')
    ->loadByProperties([
    'type' => 'radioactivity',
  ]))) {
    return $fields;
  }
  foreach ($field_storage_configs as $field_storage) {
    $fields[] = $field_storage
      ->get('field_name');
  }
  return $fields;
}