public function DraggableBlockDeriver::getDerivativeDefinitions in Draggable dashboard 8.2
Same name and namespace in other branches
- 8 src/Plugin/Block/DraggableBlockDeriver.php \Drupal\draggable_dashboard\Plugin\Block\DraggableBlockDeriver::getDerivativeDefinitions()
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- src/
Plugin/ Block/ DraggableBlockDeriver.php, line 26
Class
- DraggableBlockDeriver
- This deriver creates a block for every dashboard that has been created.
Namespace
Drupal\draggable_dashboard\Plugin\BlockCode
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];
}