AddJsClasses.php in Facets Block 8
File
src/AddJsClasses.php
View source
<?php
namespace Drupal\facets_block;
use Drupal\Component\Utility\Html;
use Drupal\Core\Security\TrustedCallbackInterface;
class AddJsClasses implements TrustedCallbackInterface {
public static function trustedCallbacks() {
return [
'preRender',
];
}
public static function preRender($elements) {
$elements['#attributes']['class'][] = 'block-facets-ajax';
if (empty($elements['#id'])) {
$elements['#id'] = Html::getUniqueId($elements['#plugin_id']);
}
$elements['#attributes']['class'][] = "js-facet-block-id-{$elements['#id']}";
return $elements;
}
}