facets_block.module in Facets Block 8
This is the primary module file.
File
facets_block.moduleView source
<?php
/**
* @file
* This is the primary module file.
*/
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function facets_block_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.facets_block':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Render Facets in a single block.') . '</p>';
return $output;
}
}
/**
* Implements hook_theme().
*/
function facets_block_theme($existing, $type, $theme, $path) {
return [
'facets_block' => [
'variables' => [
'show_title' => TRUE,
'facets' => '',
],
],
];
}
/**
* Implements hook_block_view_BASE_BLOCK_ID_alter().
*/
function facets_block_block_view_facets_block_alter(array &$build, BlockPluginInterface $block) {
if (!empty($build['#configuration']['add_js_classes'])) {
$build['#pre_render'][] = '\\Drupal\\facets_block\\AddJsClasses::preRender';
}
if (!empty($build['#configuration']['hide_empty_block'])) {
$build['#pre_render'][] = '\\Drupal\\facets_block\\AddCssClasses::preRender';
}
}
Functions
Name | Description |
---|---|
facets_block_block_view_facets_block_alter | Implements hook_block_view_BASE_BLOCK_ID_alter(). |
facets_block_help | Implements hook_help(). |
facets_block_theme | Implements hook_theme(). |