class AddCssClasses in Facets Block 8
AddCssClasses pre-render callback.
Hierarchy
- class \Drupal\facets_block\AddCssClasses implements TrustedCallbackInterface
Expanded class hierarchy of AddCssClasses
File
- src/
AddCssClasses.php, line 11
Namespace
Drupal\facets_blockView source
class AddCssClasses implements TrustedCallbackInterface {
/**
* {@inheritdoc}
*/
public static function trustedCallbacks() {
return [
'preRender',
];
}
/**
* Pre-render callback to add hidden class to empty facet block.
*/
public static function preRender($elements) {
if (empty($elements['#id'])) {
$elements['#id'] = Html::getUniqueId($elements['#plugin_id']);
}
// Hide facets block if facets array is empty.
if (empty($elements['content']['#facets'])) {
$elements['#attributes']['class'][] = 'hidden';
}
return $elements;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AddCssClasses:: |
public static | function | Pre-render callback to add hidden class to empty facet block. | |
AddCssClasses:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
|
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |