class DashboardBlock in Dashboards with Layout Builder 8
Same name in this branch
- 8 src/Plugin/Derivative/DashboardBlock.php \Drupal\dashboards\Plugin\Derivative\DashboardBlock
- 8 src/Plugin/Block/DashboardBlock.php \Drupal\dashboards\Plugin\Block\DashboardBlock
Same name and namespace in other branches
- 2.0.x src/Plugin/Derivative/DashboardBlock.php \Drupal\dashboards\Plugin\Derivative\DashboardBlock
Provides block plugin definitions for dashboard blocks.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\dashboards\Plugin\Derivative\DashboardBlock implements ContainerDeriverInterface uses StringTranslationTrait
Expanded class hierarchy of DashboardBlock
File
- src/
Plugin/ Derivative/ DashboardBlock.php, line 14
Namespace
Drupal\dashboards\Plugin\DerivativeView source
class DashboardBlock extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
/**
* Plugin manager.
*
* @var \Drupal\Component\Plugin\PluginManagerInterface
*/
protected $manager;
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$definitions = $this->manager
->getDefinitions();
foreach ($definitions as $id => $definition) {
$this->derivatives['dashboard:' . $id] = $base_plugin_definition;
$this->derivatives['dashboard:' . $id]['admin_label'] = $this
->t('@display_name', [
'@display_name' => $definition['label'],
]);
$this->derivatives['dashboard:' . $id]['category'] = $this
->t('@category', [
'@category' => $definition['category'],
]);
}
return $this->derivatives;
}
/**
* Constructs new DashboardBlock.
*
* @param \Drupal\Component\Plugin\PluginManagerInterface $plugin_manager
* The entity type manager.
*/
public function __construct(PluginManagerInterface $plugin_manager) {
$this->manager = $plugin_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('plugin.manager.dashboard'));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DashboardBlock:: |
protected | property | Plugin manager. | |
DashboardBlock:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
DashboardBlock:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DashboardBlock:: |
public | function | Constructs new DashboardBlock. | |
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
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. |