You are here

public function SearchApiStatsBlock::build in Search API Stats 8

Builds and returns the renderable array for this block plugin.

If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockViewBuilder

File

modules/search_api_stats_block/src/Plugin/Block/SearchApiStatsBlock.php, line 70

Class

SearchApiStatsBlock
Provides a 'SearchApiStatsBlock' block.

Namespace

Drupal\search_api_stats_block\Plugin\Block

Code

public function build() {
  $config = $this
    ->getConfiguration();
  $stats = $this
    ->getStats();
  return [
    '#theme' => 'search_api_stats_block',
    '#path' => $config['path'],
    '#param_name' => $config['param_name'],
    '#stats' => $stats,
    '#cache' => [
      'max-age' => 0,
    ],
  ];
}