function opigno_learning_path_preprocess_page in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 opigno_learning_path.module \opigno_learning_path_preprocess_page()
Implements hook_preprocess_page().
File
- ./
opigno_learning_path.module, line 540 - Contains opigno_learning_path.module.
Code
function opigno_learning_path_preprocess_page(&$variables) {
$route = \Drupal::routeMatch()
->getRouteName();
// Hide local tasks.
if (opigno_learning_path_is_lp_route()) {
unset($variables['page']['content']['primaryadminactions']);
}
if ($route == 'entity.group.edit_form' && ($group = \Drupal::routeMatch()
->getParameter('group'))) {
$form_builder = \Drupal::service('entity.form_builder');
$form = $form_builder
->getForm($group, 'delete', []);
// Change default link to current page.
$url = Url::fromRoute('entity.group.edit_form', [
'group' => $group
->id(),
], [
'attributes' => [
'class' => [
'button',
'close-overlay',
],
],
]);
$link = Link::fromTextAndUrl(t('Cancel'), $url)
->toRenderable();
$form['actions']['cancel']['#url'] = $url;
$variables['delete_lp_form'] = [
'#type' => 'container',
'#attributes' => [
'id' => 'delete-lp-form-overlay',
'style' => 'display: none;',
],
[
'#type' => 'container',
'#attributes' => [
'id' => 'delete-lp-form-wrapper',
],
[
'#type' => 'container',
'#attributes' => [
'class' => [
'text-right',
],
],
[
'#type' => 'html_tag',
'#tag' => 'button',
'#attributes' => [
'class' => [
'close-overlay',
],
],
'#value' => t('close'),
],
],
[
'#type' => 'container',
'form' => $form,
],
],
];
}
}