Loading widget_instance.module +7 −2 Original line number Diff line number Diff line Loading @@ -91,11 +91,12 @@ function widget_instance_options_list_alter(array &$options, array $context) { $widget_types = \Drupal::entityTypeManager() ->getStorage('widget_type') ->loadMultiple($widget_type_ids); $no_registry_source = '_widget_instance__no_widget_type_registry_source'; $options = array_reduce( $widget_types, static function (array $carry, WidgetTypeInterface $widget_type): array { static function (array $carry, WidgetTypeInterface $widget_type) use ($no_registry_source): array { $registry_source = $widget_type->widget_registry_source->entity ?? NULL; $option_group = (string) new TranslatableMarkup('Other'); $option_group = $no_registry_source; if ($registry_source instanceof EntityInterface) { $option_group = $registry_source->label(); } Loading @@ -110,4 +111,8 @@ function widget_instance_options_list_alter(array &$options, array $context) { array_walk($options, static function (array &$option_group): void { sort($option_group); }); // Move the 'Other' option group (for widget types with no registry source) // to the bottom of the select list. $options[(string) new TranslatableMarkup('Other')] = $options[$no_registry_source]; unset($options[$no_registry_source]); } Loading
widget_instance.module +7 −2 Original line number Diff line number Diff line Loading @@ -91,11 +91,12 @@ function widget_instance_options_list_alter(array &$options, array $context) { $widget_types = \Drupal::entityTypeManager() ->getStorage('widget_type') ->loadMultiple($widget_type_ids); $no_registry_source = '_widget_instance__no_widget_type_registry_source'; $options = array_reduce( $widget_types, static function (array $carry, WidgetTypeInterface $widget_type): array { static function (array $carry, WidgetTypeInterface $widget_type) use ($no_registry_source): array { $registry_source = $widget_type->widget_registry_source->entity ?? NULL; $option_group = (string) new TranslatableMarkup('Other'); $option_group = $no_registry_source; if ($registry_source instanceof EntityInterface) { $option_group = $registry_source->label(); } Loading @@ -110,4 +111,8 @@ function widget_instance_options_list_alter(array &$options, array $context) { array_walk($options, static function (array &$option_group): void { sort($option_group); }); // Move the 'Other' option group (for widget types with no registry source) // to the bottom of the select list. $options[(string) new TranslatableMarkup('Other')] = $options[$no_registry_source]; unset($options[$no_registry_source]); }