diff --git a/core/modules/field/field.module b/core/modules/field/field.module index f4a6299..0c0d153 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -5,10 +5,12 @@ */ use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\Field\FieldTypePluginManager; use Drupal\Core\Language\Language; use Drupal\Core\Template\Attribute; use Drupal\field\FieldInterface; use Drupal\field\FieldInstanceInterface; +use Drupal\field\Plugin\Type\Widget\WidgetPluginManager; /* * Load all public Field API functions. Drupal currently has no @@ -121,25 +123,29 @@ function field_help($path, $arg) { $output .= '
' . t('Enabling field types') . '
'; $output .= '
' . t('The Field module provides the infrastructure for fields and field attachment; the field types and input widgets themselves are provided by additional modules. Some of the modules are required; the optional modules can be enabled from the Modules administration page. Drupal core includes the following field type modules: Number (required), Text (required), List (required), Taxonomy (optional), Image (optional), and File (optional); the required Options module provides input widgets for other field modules. Additional fields and widgets may be provided by contributed modules, which you can find in the contributed module section of Drupal.org. Currently enabled field and input widget modules:', array('@modules' => url('admin/modules'), '@contrib' => 'http://drupal.org/project/modules', '@options' => url('admin/help/options'))); - // Make a list of all widget and field modules currently enabled, in - // order by displayed module name (module names are not translated). + // Make a list of all widget and field modules currently enabled, ordered + // by displayed module name (module names are not translated). $items = array(); $info = system_get_info('module'); - $modules = array_merge(\Drupal::moduleHandler()->getImplementations('field_info'), \Drupal::moduleHandler()->getImplementations('field_widget_info')); + $field_widgets = \Drupal::service('plugin.manager.field.widget')->getDefinitions(); + $field_types = \Drupal::service('plugin.manager.entity.field.field_type')->getDefinitions(); + foreach (array_merge($field_types, $field_widgets) as $field_module) { + $modules[] = $field_module['provider']; + } $modules = array_unique($modules); sort($modules); foreach ($modules as $module) { $display = $info[$module]['name']; if (\Drupal::moduleHandler()->implementsHook($module, 'help')) { - $items['items'][] = l($display, 'admin/help/' . $module); + $items[] = l($display, 'admin/help/' . $module); } else { - $items['items'][] = $display; + $items[] = $display; } } $item_list = array( '#theme' => 'item_list', - '#items' => $items['items'], + '#items' => $items, ); $output .= drupal_render($item_list); return $output; diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldHelpTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldHelpTest.php new file mode 100644 index 0000000..ea172eb --- /dev/null +++ b/core/modules/field/lib/Drupal/field/Tests/FieldHelpTest.php @@ -0,0 +1,69 @@ + 'Field help functionality', + 'description' => 'Verify help display for the Field module.', + 'group' => 'Field', + ); + } + + public function setUp() { + parent::setUp(); + + // Create the admin user. + $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme')); + } + + /** + * Test the Field module's help page. + */ + public function testFieldHelp() { + // Login the admin user. + $this->drupalLogin($this->adminUser); + + // Visit the Help page and make sure no warnings or notices are thrown. + $this->drupalGet('admin/help/field'); + + // Enable the Options, Telephone and E-mail modules. + \Drupal::moduleHandler()->install(array('options', 'telephone', 'email')); + \Drupal::service('plugin.manager.field.widget')->clearCachedDefinitions(); + \Drupal::service('plugin.manager.entity.field.field_type')->clearCachedDefinitions(); + + $this->drupalGet('admin/help/field'); + $this->assertLink('Options', 0, 'Options module is listed on the Field help page.'); + $this->assertLink('E-mail', 0, 'E-mail module is listed on the Field help page.'); + $this->assertText('Telephone', 'Modules with field types that do not implement hook_help are listed.'); + $this->assertNoLink('Telephone', 'Modules with field types that do not implement hook_help are not linked.'); + $this->assertNoLink('Link', 'Modules that have not been installed, are not listed.'); + } +}