You are here

public function ApiTokenBase::__construct in API Tokens 8.2

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

Constructs an ApiTokenBase object.

Parameters

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin_id for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

\Drupal\Core\Extension\ModuleHandlerInterface $module_handler: The module handler service.

\Drupal\Core\Render\RendererInterface $renderer: The renderer.

\Psr\Log\LoggerInterface $logger: The API tokens logger.

Overrides PluginBase::__construct

File

src/ApiTokenBase.php, line 99

Class

ApiTokenBase
Provides a base class for the API token plugins.

Namespace

Drupal\api_tokens

Code

public function __construct(array $configuration, $plugin_id, $plugin_definition, ModuleHandlerInterface $module_handler, RendererInterface $renderer, LoggerInterface $logger) {
  parent::__construct($configuration, $plugin_id, $plugin_definition);
  $this->moduleHandler = $module_handler;
  $this->renderer = $renderer;
  $this->logger = $logger;
  $this->paramString = isset($configuration['params']) ? $configuration['params'] : '';
  $this->token = "[api:{$plugin_id}{$this->paramString}/]";
  $this->params = $this->paramString ? Json::decode($this->paramString) : [];
  $this->hash = $this->params ? hash('crc32b', serialize($this->params)) : '';
  $this->reflector = method_exists($this, 'build') ? new \ReflectionMethod($this, 'build') : NULL;
}