function FieldListOptions::getPossibleOptions

Overrides OptionsProviderInterface::getPossibleOptions

File

src/TypedData/Options/FieldListOptions.php, line 44

Class

FieldListOptions
Options provider to return all fields in the system.

Namespace

Drupal\rules\TypedData\Options

Code

public function getPossibleOptions(AccountInterface $account = NULL) {
    $options = [];
    // Load all the fields in the system.
    $fields = $this->entityFieldManager
        ->getFieldMap();
    // Add each field to our options array.
    foreach ($fields as $entity_fields) {
        foreach ($entity_fields as $field_name => $field) {
            $options[$field_name] = $field_name . ' (' . $field['type'] . ')';
        }
    }
    // Sort the result by value for ease of locating and selecting.
    asort($options);
    return $options;
}