public function DateApiToken::build in API Tokens 8
Same name and namespace in other branches
- 8.2 api_tokens_example/src/Plugin/ApiToken/DateApiToken.php \Drupal\api_tokens_example\Plugin\ApiToken\DateApiToken::build()
Build callback.
Parameters
string $format: (optional) The date format. Defaults to "U".
return array A renderable array.
See also
\Drupal\api_tokens\ApiTokenPluginInterface::build();
File
- api_tokens_example/
src/ Plugin/ ApiToken/ DateApiToken.php, line 33
Class
- DateApiToken
- Provides a Date API token.
Namespace
Drupal\api_tokens_example\Plugin\ApiTokenCode
public function build($format = 'U') {
$this
->mergeCacheMaxAge(0);
$build = [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => date($format),
'#attributes' => [
'class' => 'api-token-date',
],
'#attached' => [
'library' => [
'api_tokens_example/date',
],
],
];
return $build;
}