class ConfigurableTestClass
A test class using ConfigurablePluginTrait that can modify the de.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Tests\Core\Plugin\ConfigurableTestClass extends \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\ConfigurableInterface uses \Drupal\Core\Plugin\ConfigurableTrait
Expanded class hierarchy of ConfigurableTestClass
File
-
core/
tests/ Drupal/ Tests/ Core/ Plugin/ ConfigurableTraitTest.php, line 168
Namespace
Drupal\Tests\Core\PluginView source
class ConfigurableTestClass extends PluginBase implements ConfigurableInterface {
use ConfigurableTrait {
defaultConfiguration as traitDefaultConfiguration;
}
/**
* A default configuration for the test class to return.
*
* @var array|null
*/
protected ?array $defaultConfiguration = NULL;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration = [], string $plugin_id = '', array $plugin_definition = []) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->setConfiguration($configuration);
}
/**
* Sets the default configuration this test will return.
*
* @param array $default_configuration
* The default configuration to use.
*/
public function setDefaultConfiguration(array $default_configuration) : void {
$this->defaultConfiguration = $default_configuration;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() : array {
return $this->defaultConfiguration ?? $this->traitDefaultConfiguration();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.