-
Notifications
You must be signed in to change notification settings - Fork 0
/
facets_block.module
49 lines (43 loc) · 1.15 KB
/
facets_block.module
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?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';
}
}