abstract class DashboardBase in Dashboards with Layout Builder 8
Same name and namespace in other branches
- 2.0.x src/Plugin/DashboardBase.php \Drupal\dashboards\Plugin\DashboardBase
Base class for Dashboard plugins.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\dashboards\Plugin\DashboardBase implements ContainerFactoryPluginInterface, DashboardInterface uses StringTranslationTrait
Expanded class hierarchy of DashboardBase
13 files declare their use of DashboardBase
- Account.php in src/
Plugin/ Dashboard/ Account.php - AddContentMenu.php in src/
Plugin/ Dashboard/ AddContentMenu.php - Browser.php in modules/
dashboards_matomo/ src/ Plugin/ Dashboard/ Browser.php - Comments.php in modules/
dashboards_comments/ src/ Plugin/ Dashboard/ Comments.php - Country.php in modules/
dashboards_matomo/ src/ Plugin/ Dashboard/ Country.php
File
- src/
Plugin/ DashboardBase.php, line 15
Namespace
Drupal\dashboards\PluginView source
abstract class DashboardBase extends PluginBase implements DashboardInterface, ContainerFactoryPluginInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('dashboards.cache'));
}
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, CacheBackendInterface $cache_backend) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $plugin_definition);
$this->cache = $cache_backend;
}
/**
* Cache backend.
*
* @var \Drupal\Core\Cache\CacheBackendInterface
*/
protected $cache;
/**
* Build render array.
*
* @param array $configuration
* Plugin configuration.
*
* @return array
* Return render array.
*/
public abstract function buildRenderArray(array $configuration) : array;
/**
* Build render array.
*
* @param array $form
* Default form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Default form.
* @param array $configuration
* Configuration.
*
* @return array
* Return form array.
*/
public function buildSettingsForm(array $form, FormStateInterface $form_state, array $configuration) : array {
return $form;
}
/**
* Validate settings form.
*
* @param array $form
* Default form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Default form.
* @param array $configuration
* Configuration.
*/
public function validateForm(array $form, FormStateInterface $form_state, array $configuration) : void {
}
/**
* Validate settings form.
*
* @param array $form
* Default form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* Default form.
* @param array $configuration
* Configuration.
*/
public function massageFormValues(array $form, FormStateInterface $form_state, array $configuration) : void {
}
/**
* Get cache for cid.
*
* @param string $cid
* Cache id.
*
* @return mixed
* Return cache data.
*/
protected function getCache(string $cid) {
return $this->cache
->get($this
->getPluginId() . ':' . $cid);
}
/**
* Set a new cache entry. Cache is prefixed by pluginid.
*
* @param string $cid
* Cache id.
* @param mixed $data
* Data to cache.
* @param int $expire
* Expire data. Default to 3600.
* @param array $tags
* Tags for invalidation.
*/
protected function setCache(string $cid, $data, int $expire = 3600, array $tags = []) : void {
$this->cache
->set($this
->getPluginId() . ':' . $cid, $data, $expire, $tags);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DashboardBase:: |
protected | property | Cache backend. | |
DashboardBase:: |
abstract public | function | Build render array. | 8 |
DashboardBase:: |
public | function | Build render array. | 9 |
DashboardBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
8 |
DashboardBase:: |
protected | function | Get cache for cid. | |
DashboardBase:: |
public | function | Validate settings form. | |
DashboardBase:: |
protected | function | Set a new cache entry. Cache is prefixed by pluginid. | |
DashboardBase:: |
public | function | Validate settings form. | 1 |
DashboardBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
8 |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |