Skip to content
Snippets Groups Projects

Refactored the facet block label code

1 file
+ 3
9
Compare changes
  • Side-by-side
  • Inline
@@ -256,15 +256,9 @@ class FacetsBlock extends BlockBase implements ContainerFactoryPluginInterface {
$build['#attributes'] = [];
}
if (
isset($build['0']['#facet']) &&
$build['0']['#facet'] instanceof FacetInterface
) {
$title = $build['0']['#facet']->getName();
}
else {
$title = $block_plugin->label();
}
/** @var \Drupal\facets\Entity\Facet $facet */
$facet = $this->entityTypeManager->getStorage('facets_facet')->load($block_plugin->getDerivativeId());
$title = ($facet instanceof FacetInterface) ? $facet->getName() : $block_plugin->label();
// Inject unique class per facet.
$build['#attributes']['class'][] = strtr($plugin_id, '_:', '--');
Loading