function FieldTypePluginManager::getUiDefinitions

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Field/FieldTypePluginManager.php \Drupal\Core\Field\FieldTypePluginManager::getUiDefinitions()
  2. 8.9.x core/lib/Drupal/Core/Field/FieldTypePluginManager.php \Drupal\Core\Field\FieldTypePluginManager::getUiDefinitions()
  3. 10 core/lib/Drupal/Core/Field/FieldTypePluginManager.php \Drupal\Core\Field\FieldTypePluginManager::getUiDefinitions()

Gets the definition of all field types that can be added via UI.

If the field type extends \Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface, then include the preconfigured definitions. The key is 'field_ui', the base field name, and the key from getPreconfiguredOptions(), joined with ':'.

Return value

array An array of field type definitions.

Overrides FieldTypePluginManagerInterface::getUiDefinitions

1 call to FieldTypePluginManager::getUiDefinitions()
FieldTypePluginManager::getEntityTypeUiDefinitions in core/lib/Drupal/Core/Field/FieldTypePluginManager.php
Get the field type definitions that can be added via UI for an entity type.

File

core/lib/Drupal/Core/Field/FieldTypePluginManager.php, line 203

Class

FieldTypePluginManager
Plugin manager for 'field type' plugins.

Namespace

Drupal\Core\Field

Code

public function getUiDefinitions() {
  $definitions = $this->getDefinitions();
  // Filter out definitions that can not be configured in Field UI.
  $definitions = array_filter($definitions, function ($definition) {
    return empty($definition['no_ui']);
  });
  // Add preconfigured definitions.
  foreach ($definitions as $id => $definition) {
    if (is_subclass_of($definition['class'], '\\Drupal\\Core\\Field\\PreconfiguredFieldUiOptionsInterface')) {
      foreach ($this->getPreconfiguredOptions($definition['id']) as $key => $option) {
        $definitions["field_ui:{$id}:{$key}"] = array_intersect_key($option, [
          'label' => 0,
          'category' => 1,
          'weight' => 1,
          'description' => 0,
        ]) + $definition;
      }
    }
  }
  return $definitions;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.