function views_ui_entity_operation
Implements hook_entity_operation().
1 call to views_ui_entity_operation()
- ViewsBlockTest::testOperationLinks in core/
modules/ views_ui/ tests/ src/ Kernel/ ViewsBlockTest.php - Tests the editing links for ViewsBlockBase.
File
-
core/
modules/ views_ui/ views_ui.module, line 360
Code
function views_ui_entity_operation(EntityInterface $entity) : array {
$operations = [];
if ($entity instanceof BlockInterface) {
$plugin = $entity->getPlugin();
if ($plugin->getBaseId() === 'views_block') {
$view_id_parts = explode('-', $plugin->getDerivativeId());
$view_id = $view_id_parts[0] ?? '';
$display_id = $view_id_parts[1] ?? '';
$view = View::load($view_id);
if ($view && $view->access('edit')) {
$operations['view-edit'] = [
'title' => t('Edit view'),
'url' => Url::fromRoute('entity.view.edit_display_form', [
'view' => $view_id,
'display_id' => $display_id,
]),
'weight' => 50,
];
}
}
}
return $operations;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.