You are here

public static function ApiTokenBase::lazyBuilder in API Tokens 8.2

Same name and namespace in other branches
  1. 8 src/ApiTokenBase.php \Drupal\api_tokens\ApiTokenBase::lazyBuilder()

The #lazy_builder callback.

Parameters

string $id: The API token ID.

string $params: Parameters part of the API token string.

bool $valid: Whether the API token is valid.

Return value

array A renderable array for the API token output.

Overrides ApiTokenPluginInterface::lazyBuilder

File

src/ApiTokenBase.php, line 333

Class

ApiTokenBase
Provides a base class for the API token plugins.

Namespace

Drupal\api_tokens

Code

public static function lazyBuilder($id, $params, $valid) {
  $plugin = \Drupal::service('plugin.manager.api_token')
    ->createInstance($id, [
    'params' => $params,
  ]);
  return $valid ? $plugin
    ->process() : $plugin
    ->fallback();
}