You are here

class AddJsClasses in Facets Block 8

AddJsClasses pre-render callback.

Hierarchy

Expanded class hierarchy of AddJsClasses

File

src/AddJsClasses.php, line 11

Namespace

Drupal\facets_block
View source
class AddJsClasses implements TrustedCallbackInterface {

  /**
   * {@inheritdoc}
   */
  public static function trustedCallbacks() {
    return [
      'preRender',
    ];
  }

  /**
   * Pre-render callback to add js classes to the facets_block block.
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddJsClasses::preRender public static function Pre-render callback to add js classes to the facets_block block.
AddJsClasses::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.