public function SliderBlock::getDerivativeDefinitions in Image sliders 8
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/ Derivative/ SliderBlock.php, line 46
Class
- SliderBlock
- Provides a form for generating multiple block.
Namespace
Drupal\image_slider\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
// @todo might as well include your configuration here and assign a
// value.
$slider_data = [];
$slider_data = $this->database
->select('slider', 's')
->fields('s')
->execute()
->FetchAll();
if (is_array($slider_data) && count($slider_data) > 0) {
foreach ($slider_data as $val) {
$this->derivatives[$val->id] = $base_plugin_definition;
$this->derivatives[$val->id]['admin_label'] = $val->name;
}
}
else {
$slider_data = [
'0' => 'Slider Demo',
];
foreach ($slider_data as $key => $val) {
$this->derivatives[$key] = $base_plugin_definition;
$this->derivatives[$key]['admin_label'] = $val;
}
}
return $this->derivatives;
}