Implements \Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().
Overrides DerivativeInterface::getDerivativeDefinitions
public function getDerivativeDefinitions(array $base_plugin_definition) {
// Check all Views for block displays.
foreach (views_get_all_views() as $view) {
// Do not return results for disabled views.
if (!$view
->status()) {
continue;
}
$executable = $view
->get('executable');
$executable
->initDisplay();
foreach ($executable->displayHandlers as $display) {
// Add a block plugin definition for each block display.
if (isset($display) && !empty($display->definition['uses_hook_block'])) {
$delta = $view
->id() . '-' . $display->display['id'];
$desc = $display
->getOption('block_description');
if (empty($desc)) {
if ($display->display['display_title'] == $display->definition['title']) {
$desc = t('View: !view', array(
'!view' => $view
->label(),
));
}
else {
$desc = t('View: !view: !display', array(
'!view' => $view
->label(),
'!display' => $display->display['display_title'],
));
}
}
$this->derivatives[$delta] = array(
'admin_label' => $desc,
'cache' => $display
->getCacheType(),
);
$this->derivatives[$delta] += $base_plugin_definition;
}
}
}
return $this->derivatives;
}