function FieldUiAssertTrait::getFieldFromGroup

Same name and namespace in other branches
  1. main core/modules/field_ui/tests/src/Traits/FieldUiAssertTrait.php \Drupal\Tests\field_ui\Traits\FieldUiAssertTrait::getFieldFromGroup()

Helper function that returns the name of the group that a field is in.

Parameters

string $field_type: The name of the field type.

Return value

string|null Group name

3 calls to FieldUiAssertTrait::getFieldFromGroup()
FieldUiJSTestTrait::fieldUIAddNewFieldJS in core/modules/field_ui/tests/src/Traits/FieldUiJSTestTrait.php
Creates a new field through the Field UI.
FieldUiTestTrait::fieldUIAddNewField in core/modules/field_ui/tests/src/Traits/FieldUiTestTrait.php
Creates a new field through the Field UI.
ManageFieldsTest::testHiddenFields in core/modules/field_ui/tests/src/Kernel/ManageFieldsTest.php
Tests that Field UI respects the 'no_ui' flag in the field type definition.

File

core/modules/field_ui/tests/src/Traits/FieldUiAssertTrait.php, line 21

Class

FieldUiAssertTrait
Provides assertions and helpers for Field UI test classes.

Namespace

Drupal\Tests\field_ui\Traits

Code

protected function getFieldFromGroup($field_type) : ?string {
  /** @var \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_plugin_manager */
  $field_type_plugin_manager = \Drupal::service('plugin.manager.field.field_type');
  $grouped_field_types = $field_type_plugin_manager->getGroupedDefinitions($field_type_plugin_manager->getUiDefinitions());
  foreach ($grouped_field_types as $group => $field_types) {
    if (array_key_exists($field_type, $field_types)) {
      return $group;
    }
  }
  return NULL;
}

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