class FieldListOptions
Options provider to return all fields in the system.
Hierarchy
- class \Drupal\rules\TypedData\Options\OptionsProviderBase implements \Drupal\Core\TypedData\OptionsProviderInterface uses \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\rules\TypedData\Options\FieldListOptions extends \Drupal\rules\TypedData\Options\OptionsProviderBase implements \Drupal\Core\DependencyInjection\ContainerInjectionInterface
Expanded class hierarchy of FieldListOptions
1 file declares its use of FieldListOptions
- OptionsProviderTest.php in tests/
src/ Functional/ OptionsProvider/ OptionsProviderTest.php
File
-
src/
TypedData/ Options/ FieldListOptions.php, line 13
Namespace
Drupal\rules\TypedData\OptionsView source
class FieldListOptions extends OptionsProviderBase implements ContainerInjectionInterface {
/**
* The entity field manager service.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager;
/**
* Constructs a FieldListOptions object.
*
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager service.
*/
public function __construct(EntityFieldManagerInterface $entity_field_manager) {
$this->entityFieldManager = $entity_field_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container->get('entity_field.manager'));
}
/**
* {@inheritdoc}
*/
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;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
FieldListOptions::$entityFieldManager | protected | property | The entity field manager service. | ||
FieldListOptions::create | public static | function | Instantiates a new instance of this class. | Overrides ContainerInjectionInterface::create | |
FieldListOptions::getPossibleOptions | public | function | Returns an array of possible values with labels for display. | Overrides OptionsProviderInterface::getPossibleOptions | |
FieldListOptions::__construct | public | function | Constructs a FieldListOptions object. | ||
OptionsProviderBase::getPossibleValues | public | function | Returns an array of possible values. | Overrides OptionsProviderInterface::getPossibleValues | |
OptionsProviderBase::getSettableOptions | public | function | Returns an array of settable values with labels for display. | Overrides OptionsProviderInterface::getSettableOptions | |
OptionsProviderBase::getSettableValues | public | function | Returns an array of settable values. | Overrides OptionsProviderInterface::getSettableValues | |
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | |
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | ||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | ||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | ||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | |
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. |