Commit 2b15e08d authored by borisson_'s avatar borisson_ Committed by borisson_

Issue #2755571 by borisson_, mollux: Add widget type to facet block classes array

parent 63d35e99
......@@ -5,7 +5,9 @@
* Contains facets.module
*/
use Drupal\Component\Utility\Html;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Entity\FacetSource;
use Drupal\search_api\Query\QueryInterface;
use Drupal\views\Entity\View;
......@@ -94,3 +96,16 @@ function facets_entity_presave(EntityInterface $entity) {
}
}
/**
* Implements hook_preprocess_block().
*
* Adds a class for the widget to the facet block to allow for more specific
* styling.
*/
function facets_preprocess_block(&$variables) {
if ($variables['configuration']['provider'] == 'facets') {
$facet = Facet::load($variables['derivative_plugin_id']);
$variables['attributes']['class'][] = 'block-facet-widget--' . Html::cleanCssIdentifier($facet->getWidget()['type']);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment