You are here

public static function AddCssClasses::preRender in Facets Block 8

Pre-render callback to add hidden class to empty facet block.

File

src/AddCssClasses.php, line 23

Class

AddCssClasses
AddCssClasses pre-render callback.

Namespace

Drupal\facets_block

Code

public static function preRender($elements) {
  if (empty($elements['#id'])) {
    $elements['#id'] = Html::getUniqueId($elements['#plugin_id']);
  }

  // Hide facets block if facets array is empty.
  if (empty($elements['content']['#facets'])) {
    $elements['#attributes']['class'][] = 'hidden';
  }
  return $elements;
}