public function ViewsBlock::getDerivativeDefinitions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Plugin/Derivative/ViewsBlock.php \Drupal\views\Plugin\Derivative\ViewsBlock::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 DeriverInterface::getDerivativeDefinitions
See also
getDerivativeDefinition()
1 call to ViewsBlock::getDerivativeDefinitions()
- ViewsBlock::getDerivativeDefinition in core/
modules/ views/ src/ Plugin/ Derivative/ ViewsBlock.php - Gets the definition of a derivative plugin.
File
- core/
modules/ views/ src/ Plugin/ Derivative/ ViewsBlock.php, line 80 - Contains \Drupal\views\Plugin\Derivative\ViewsBlock.
Class
- ViewsBlock
- Provides block plugin definitions for all Views block displays.
Namespace
Drupal\views\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
// Check all Views for block displays.
foreach ($this->viewStorage
->loadMultiple() as $view) {
// Do not return results for disabled views.
if (!$view
->status()) {
continue;
}
$executable = $view
->getExecutable();
$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'];
$admin_label = $display
->getOption('block_description');
if (empty($admin_label)) {
if ($display->display['display_title'] == $display->definition['title']) {
$admin_label = $view
->label();
}
else {
// Allow translators to control the punctuation. Plugin
// definitions get cached, so use TranslatableMarkup() instead of
// t() to avoid double escaping when $admin_label is rendered
// during requests that use the cached definition.
$admin_label = new TranslatableMarkup('@view: @display', [
'@view' => $view
->label(),
'@display' => $display->display['display_title'],
]);
}
}
$this->derivatives[$delta] = array(
'category' => $display
->getOption('block_category'),
'admin_label' => $admin_label,
'config_dependencies' => array(
'config' => array(
$view
->getConfigDependencyName(),
),
),
);
$this->derivatives[$delta] += $base_plugin_definition;
}
}
}
return $this->derivatives;
}