public function JsCallbackBase::__construct in JS Callback Handler 8.3
Constructs a \Drupal\Component\Plugin\PluginBase 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.
Overrides PluginBase::__construct
1 call to JsCallbackBase::__construct()
- Content::__construct in src/
Plugin/ Js/ Content.php - Constructs a \Drupal\Component\Plugin\PluginBase object.
1 method overrides JsCallbackBase::__construct()
- Content::__construct in src/
Plugin/ Js/ Content.php - Constructs a \Drupal\Component\Plugin\PluginBase object.
File
- src/
Plugin/ Js/ JsCallbackBase.php, line 49
Class
- JsCallbackBase
- Base JsCallback class.
Namespace
Drupal\js\Plugin\JsCode
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->classResolver = \Drupal::service('class_resolver');
$this->js = \Drupal::service('js.callback');
$this->paramConversion = \Drupal::service('route_enhancer.param_conversion');
$this->title = isset($this->pluginDefinition['title']) ? $this->pluginDefinition['title'] : '';
try {
$this->response = $this->classResolver
->getInstanceFromDefinition($this->pluginDefinition['response']);
} catch (\Exception $e) {
// Intentionally left empty since this is checked below.
}
if (!$this->response instanceof JsResponse) {
throw new \InvalidArgumentException('JS Callback requires that the "response" option be either a service identifier or a class name creating an instance that is or inherits from \\Drupal\\js\\JsResponse.');
}
$this->parameters = $this
->convertParameters();
}