You are here

protected function FacetsBlock::getAvailableFacets in Facets Block 8

Returns a list of available facets.

Return value

array An array of enabled facets.

2 calls to FacetsBlock::getAvailableFacets()
FacetsBlock::blockForm in src/Plugin/Block/FacetsBlock.php
FacetsBlock::buildFacets in src/Plugin/Block/FacetsBlock.php
Builds facets.

File

src/Plugin/Block/FacetsBlock.php, line 148

Class

FacetsBlock
Provides a 'Facets Block' block.

Namespace

Drupal\facets_block\Plugin\Block

Code

protected function getAvailableFacets() {
  $enabled_facets = $this->facetsManager
    ->getEnabledFacets();
  uasort($enabled_facets, [
    $this,
    'sortFacetsByWeight',
  ]);
  $available_facets = [];
  if ($this->moduleHandler
    ->moduleExists('facets_summary')) {
    $available_facets['facets_summary_block:summary'] = $this
      ->t('Summary');
  }
  foreach ($enabled_facets as $facet) {

    /** @var \Drupal\facets\Entity\Facet $facet */
    $available_facets['facet_block:' . $facet
      ->id()] = $facet
      ->getName();
  }
  return $available_facets;
}