moved everything that references cases view into defaults
This commit is contained in:
@ -61,3 +61,32 @@ function opencase_defaults_theme() {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_block_access
|
||||
*
|
||||
* Forbids the opencase_contextual_menu block on pages where it has no content.
|
||||
* (Without this, it was displaying an empty sidebar)
|
||||
*/
|
||||
function opencase_defaults_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\Core\Session\AccountInterface $account) {
|
||||
if ($operation == 'view' && $block->getPluginId() == 'opencase_contextual_menu') {
|
||||
$route_name = \Drupal::routeMatch()->getRouteName();
|
||||
$routes_where_it_should_be_shown = [
|
||||
'entity.oc_actor.canonical',
|
||||
'entity.oc_actor.edit_form',
|
||||
'view.cases.page_1',
|
||||
'entity.oc_case.canonical',
|
||||
'entity.oc_case.edit_form',
|
||||
'entity.oc_case.add_form',
|
||||
'view.activities.page_1',
|
||||
'entity.oc_activity.canonical',
|
||||
'entity.oc_activity.edit_form',
|
||||
'entity.oc_activity.add_form',
|
||||
];
|
||||
return AccessResult::forbiddenIf(!in_array($route_name, $routes_where_it_should_be_shown))->addCacheableDependency($block);
|
||||
}
|
||||
|
||||
// No opinion.
|
||||
return AccessResult::neutral();
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user