' . t('About') . ''; $output .= '

' . t('OpenCase Default Configuration') . '

'; return $output; default: } } /** * Implements hook_preprocess_page_title * * Modify the page title to include more information */ function opencase_defaults_preprocess_page_title(&$variables) { $route_name = \Drupal::routeMatch()->getRouteName(); switch ($route_name) { case 'entity.oc_case.canonical': $case = \Drupal::routeMatch()->getParameter('oc_case'); $variables['title'] = $case->getName() . ": Case Details and Files"; break; case 'view.cases.page_1': $actor_id = \Drupal::routeMatch()->getParameter('actor_id'); $actor = \Drupal::entityTypeManager()->getStorage('oc_actor')->load($actor_id); $variables['title'] = $actor->getName() . ": Cases"; break; case 'view.activities.page_1': $case_id = \Drupal::routeMatch()->getParameter('case_id'); $case = \Drupal::entityTypeManager()->getStorage('oc_case')->load($case_id); $variables['title'] = $case->getName() . ": Activities"; break; } } /** * Implements hook_theme(). */ function opencase_defaults_theme() { return [ 'opencase_defaults' => [ 'render element' => 'children', ], ]; } /** * 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(); }