public function ViewsBadge::getDerivativeDefinitions in Link Badges 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/ ViewsBadge.php, line 16
Class
- ViewsBadge
- Views-based Link Badges
Namespace
Drupal\link_badges\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
$badge_views = Views::getApplicableViews('uses_link_badge');
foreach ($badge_views as $data) {
list($view_id, $display_id) = $data;
$view = Views::getView($view_id);
$display = $view
->getDisplay($display_id);
$id = $view->storage
->id() . ':' . $display_id;
$this->derivatives[$id] = $base_plugin_definition;
$this->derivatives[$id] += array(
'properties' => array(
'name' => $view->storage
->id(),
'display_id' => $display_id,
),
'label' => $view->storage
->label() . ': ' . $display->options['title'],
);
}
return $this->derivatives;
}