Content types are not transform to it labels.
My variant of ListItemProcessor:
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigManagerInterface $config_manager, EntityFieldManagerInterface $entity_field_manager) {
.....
$this->entityTypeBundleInfo = \Drupal::service('entity_type.bundle.info');
}
public function build(FacetInterface $facet, array $results) {
....
$allowed_values = $field->getSetting('allowed_values');
if (empty($allowed_values) && $function = $field->getSetting('allowed_values_function')) {
$allowed_values = ${$function}($field);
}
if (empty($allowed_values) && $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity)) {
foreach ($bundles as $key => $bundle) {
$allowed_values[$key] = $bundle['label'];
}
}
....
}
Comments
Comment #2
divined commentedComment #3
sylvainm commentedThanks, I dit the attached patch, which works for me ;-)
Comment #6
sylvainm commentedWith attached patch, test should be ok now
Comment #9
sylvainm commentedWell, hope this one will be green...
Comment #10
borisson_This changed the __contruct, so we needed to update the docblock for that as well, this expands the description. Also adds a unit test.
Comment #11
sylvainm commentedThanks
Comment #13
borisson_Committed and pushed, thanks for helping!
Comment #14
john franklin commented#10 mostly works on our site. Unless the machine name of the bundle has an underscore, in which case it shows the underscoreless version of the machine name. e.g., 'news_story' => 'News Story' shows 'newsstory'.
I cherry-picked this specific patch for our site. If it works for you guys, that would mean there is a dependent patch to handle the underscore.