Namespace
Drupal\rules\TypedData\Options
File
-
src/TypedData/Options/FieldListOptions.php
View source
<?php
namespace Drupal\rules\TypedData\Options;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Entity\EntityFieldManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FieldListOptions extends OptionsProviderBase implements ContainerInjectionInterface {
protected $entityFieldManager;
public function __construct(EntityFieldManagerInterface $entity_field_manager) {
$this->entityFieldManager = $entity_field_manager;
}
public static function create(ContainerInterface $container) {
return new static($container->get('entity_field.manager'));
}
public function getPossibleOptions(AccountInterface $account = NULL) {
$options = [];
$fields = $this->entityFieldManager
->getFieldMap();
foreach ($fields as $entity_fields) {
foreach ($entity_fields as $field_name => $field) {
$options[$field_name] = $field_name . ' (' . $field['type'] . ')';
}
}
asort($options);
return $options;
}
}
Classes
| Title |
Deprecated |
Summary |
| FieldListOptions |
|
Options provider to return all fields in the system. |