Skip to content

Commit

Permalink
WFG-995-52801 Hide embed tab on webform
Browse files Browse the repository at this point in the history
  • Loading branch information
juuliabellcom committed Jan 17, 2022
1 parent 8d03bcf commit 19ebdc9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions os2forms.module
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,33 @@ function _os2forms_migrate_prepare_webform2pdf_get_template($nid, $source) {

return $template;
}

/**
* Implements hook_menu_local_tasks_alter().
*/
function os2forms_menu_local_tasks_alter(&$data, $route_name) {
$webform = \Drupal::routeMatch()->getParameter('webform');
$routeName = \Drupal::routeMatch()->getRouteName();
if ($webform && $routeName == $route_name) {
if (is_object($webform)) {
$webform = $webform->id();
}
if (isset ($data['tabs'][0]['entity.webform.embed']) && !\Drupal::currentUser()->hasPermission('os2forms embed webform access') ) {
unset($data['tabs'][0]['entity.webform.embed']);
}
}
}

/**
* Implements hook_module_implements_alter().
*/
function os2forms_module_implements_alter(&$implementations, $hook) {
switch ($hook) {
// Move our hook_entity_type_alter() implementation to the end of the list.
case 'menu_local_tasks_alter':
$group = $implementations['os2forms'];
unset($implementations['os2forms']);
$implementations['os2forms'] = $group;
break;
}
}
4 changes: 4 additions & 0 deletions os2forms.permissions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
os2forms embed webform access:
title: 'Access to Embed webform tab'
description: 'Permission for access to Embed webform tab.'
restrict access: TRUE

0 comments on commit 19ebdc9

Please sign in to comment.