class DraggableBlockDeriver in Draggable dashboard 8
Same name and namespace in other branches
- 8.2 src/Plugin/Block/DraggableBlockDeriver.php \Drupal\draggable_dashboard\Plugin\Block\DraggableBlockDeriver
This deriver creates a block for every dashboard that has been created.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\draggable_dashboard\Plugin\Block\DraggableBlockDeriver implements ContainerDeriverInterface
Expanded class hierarchy of DraggableBlockDeriver
File
- src/
Plugin/ Block/ DraggableBlockDeriver.php, line 14
Namespace
Drupal\draggable_dashboard\Plugin\BlockView source
class DraggableBlockDeriver extends DeriverBase implements ContainerDeriverInterface {
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static();
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$base_plugin_id = $base_plugin_definition['id'];
if (!isset($this->derivatives[$base_plugin_id])) {
$plugin_derivatives = [];
$dashboards = \Drupal::entityQuery('dashboard_entity')
->execute();
foreach ($dashboards as $dashboardID) {
$dashboard = DashboardEntity::load($dashboardID);
$machine_name = 'draggable_dashboard_' . $dashboardID;
$plugin_derivatives[$machine_name] = [
'id' => $base_plugin_id . PluginBase::DERIVATIVE_SEPARATOR . $machine_name,
'label' => t('Dashboard: :dashboard', [
':dashboard' => $dashboard
->get('title'),
]),
'admin_label' => $dashboard
->get('title'),
'description' => $dashboard
->get('description'),
] + $base_plugin_definition;
}
$this->derivatives[$base_plugin_id] = $plugin_derivatives;
}
return $this->derivatives[$base_plugin_id];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
DraggableBlockDeriver:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
DraggableBlockDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |