diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php index d0410e0..a605129 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php @@ -9,6 +9,7 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Core\Plugin\Discovery\CacheDecorator; +use Drupal\Core\Plugin\Discovery\AlterDecorator; use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery; use Drupal\field\Plugin\Type\Widget\WidgetLegacyDiscoveryDecorator; @@ -44,7 +45,7 @@ class WidgetPluginManager extends PluginManagerBase { * Constructs a WidgetPluginManager object. */ public function __construct() { - $this->baseDiscovery = new WidgetLegacyDiscoveryDecorator(new AnnotatedClassDiscovery('field', 'widget')); + $this->baseDiscovery = new AlterDecorator(new WidgetLegacyDiscoveryDecorator(new AnnotatedClassDiscovery('field', 'widget')), 'field_widget_info'); $this->discovery = new CacheDecorator($this->baseDiscovery, $this->cache_id, $this->cache_bin); $this->factory = new WidgetFactory($this); diff --git a/core/modules/field/lib/Drupal/field/Tests/WidgetTest.php b/core/modules/field/lib/Drupal/field/Tests/WidgetTest.php new file mode 100644 index 0000000..db81335 --- /dev/null +++ b/core/modules/field/lib/Drupal/field/Tests/WidgetTest.php @@ -0,0 +1,45 @@ + 'Field Widget tests', + 'description' => 'Test field widgets.', + 'group' => 'Field API', + ); + } + + /** + * Test the definitions of a widget. + */ + function testWidgetDefinitions() { + + $widget_definition = field_get_plugin_manager('widget')->getDefinition('options_select'); + + // Test if hook_field_widget_info_alter is beïng called. + $this->assertTrue(in_array('taxonomy_term_reference', $widget_definition['field types']), 'hook_field_widget_info_alter is beïng called'); + + } + +}