You are here

public function DropdownWidget::build in Facets 8

Builds the facet widget for rendering.

Parameters

\Drupal\facets\FacetInterface $facet: The facet we need to build.

Return value

array A renderable array.

Overrides WidgetPluginBase::build

File

src/Plugin/facets/widget/DropdownWidget.php, line 32

Class

DropdownWidget
The dropdown widget.

Namespace

Drupal\facets\Plugin\facets\widget

Code

public function build(FacetInterface $facet) {
  $build = parent::build($facet);
  $build['#attributes']['class'][] = 'js-facets-dropdown-links';
  $build['#attached']['drupalSettings']['facets']['dropdown_widget'][$facet
    ->id()]['facet-default-option-label'] = $this
    ->getConfiguration()['default_option_label'];
  $build['#attached']['library'][] = 'facets/drupal.facets.dropdown-widget';
  $build['#attached']['library'][] = 'facets/drupal.facets.general';
  return $build;
}