- Issue created by @acbramley
- 🇬🇧United Kingdom longwave UK
Given the function is just
return array_map(function ($bundle_info) { return $bundle_info['label']; }, \Drupal::service('entity_type.bundle.info')->getBundleInfo('node'));
this could be added as a convenience method to EntityTypeBundleInfo so you can call e.g.
$labels = \Drupal::service('entity_type.bundle.info')->getBundleLabels('node');
- 🇦🇺Australia acbramley
I like that approach, adding a new method to an interface is always contentious but let's see.
The Needs Review Queue Bot → tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide → to find step-by-step guides for working with issues.
- 🇨ðŸ‡Switzerland berdir Switzerland
Somewhat mixed thoughts on whether a helper on an existing class/interface is necessary, with the corresponding unlikely but theoretical disruption that brings.
There are handful of examples that could use it and where we'd save a line or two, such as \Drupal\media\Plugin\Filter\MediaEmbed::settingsForm(), but I had to search quite a bit to find such a straightforward example in core. Most cases are not quite as obvious, some also need the description, some need to filter it to a subset of that (although that could be simplified too with an array_intersect_key(), such as \Drupal\media\Hook\MediaHooks::fieldWidgetCompleteFormAlter()), many just need one label.
But technically, this is fine, so I'll leave to decision of whether we want a replacement for this to a core maintainer. There are a fair amount of calls to that function in contrib, as per node-type settings are pretty common.
- 🇬🇧United Kingdom catch
It'd be good to open an issue to use this in
\Drupal\media\Plugin\Filter\MediaEmbed::settingsForm()
and anywhere else that makes sense. - 🇦🇺Australia acbramley
- 🇬🇧United Kingdom catch
I think the helper is worth it - we have at least one place to use it in core and several in contrib. If we ever decide it isn't worth it, we could deprecate the new helper.
Committed/pushed to 11.x, thanks!
Given this is for removal in 13.0.0 not going to worry about a backport to 10.6
Now that this issue is closed, please review the contribution record.
As a contributor, attribute any organization helped you, or if you volunteered your own time.
Maintainers, please credit people who helped resolve this issue.