You are here

function hook_api_token_build_alter in API Tokens 8

Same name and namespace in other branches
  1. 8.2 api_tokens.api.php \hook_api_token_build_alter()

Alter the result of \Drupal\api_tokens\ApiTokenPluginInterface::build() method.

Parameters

array &$build: A renderable array of data, as returned from the build method of the plugin that defined the API token.

\Drupal\api_tokens\ApiTokenPluginInterface $plugin: The API token plugin instance.

Related topics

1 invocation of hook_api_token_build_alter()
ApiTokenBase::process in src/ApiTokenBase.php
Returns processed API token build.

File

./api_tokens.api.php, line 64
Hooks provided by the API Tokens module.

Code

function hook_api_token_build_alter(array &$build, \Drupal\api_tokens\ApiTokenPluginInterface $plugin) {

  // Wraps the "some" API token output in a div with "some-class" CSS class.
  if ('some' === $plugin
    ->getId()) {
    $build = [
      '#type' => 'container',
      '#attributes' => [
        'class' => 'some-class',
      ],
      $build,
    ];
  }
}