You are here

public function ApiTokenBase::validate in API Tokens 8.2

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

Validates the API token parameters.

This validation must be context-independent. For example, if some parameter is expected to be an entity ID, check only whether it is a valid entity ID, but don't check the entity existence/access (these must be checked in the build method).

Parameters

array $params: An array of named API token parameters. If an API token has more parameters then it is defined in build method, extra parameters will be named by parameter index. For example, if we have the API token [api:example[123, ["option1", "option2"], "extra1", "extra2"]/], and plugin's build method argument definition is: ...($id, $options), the $params will be:

[
  'id' => 123,
  'options' => [
    'option1',
    'option2',
  ],
  '2' => 'extra1',
  '3' => 'extra2',
];

Return value

bool

See also

\Drupal\api_tokens\ApiTokenPluginInterface::validateToken();

1 call to ApiTokenBase::validate()
ApiTokenBase::validateToken in src/ApiTokenBase.php
Performs one-time context-independent validation of the API token.
3 methods override ApiTokenBase::validate()
BlockApiToken::validate in api_tokens_example/src/Plugin/ApiToken/BlockApiToken.php
Validates the API token parameters.
NodeApiToken::validate in api_tokens_example/src/Plugin/ApiToken/NodeApiToken.php
Validates the API token parameters.
UserLinkApiToken::validate in api_tokens_example/src/Plugin/ApiToken/UserLinkApiToken.php
Validates the API token parameters.

File

src/ApiTokenBase.php, line 263

Class

ApiTokenBase
Provides a base class for the API token plugins.

Namespace

Drupal\api_tokens

Code

public function validate(array $params) {
  return TRUE;
}