public function OpignoModuleManagerController::accessItemForm in Opigno module 3.x
Same name and namespace in other branches
- 8 src/Controller/OpignoModuleManagerController.php \Drupal\opigno_module\Controller\OpignoModuleManagerController::accessItemForm()
Check the access for the activity create/edit form.
1 string reference to 'OpignoModuleManagerController::accessItemForm'
File
- src/
Controller/ OpignoModuleManagerController.php, line 44
Class
- OpignoModuleManagerController
- Controller for all the actions of the Opigno module manager.
Namespace
Drupal\opigno_module\ControllerCode
public function accessItemForm(OpignoModuleInterface $opigno_module, AccountInterface $account) {
// Allow access if the user is a platform-level content manager.
if ($account
->hasPermission('manage group content in any group')) {
return AccessResult::allowed();
}
$item = \Drupal::routeMatch()
->getParameter('item');
if (isset($item) && $item > 0) {
// If it is edit form, check activity update access.
$activity = OpignoActivity::load($item);
return $activity
->access('update', $account, TRUE);
}
// Check activity create access.
$create_access = \Drupal::entityTypeManager()
->getAccessControlHandler('opigno_activity')
->createAccess('opigno_activity', $account);
if ($create_access) {
return AccessResult::allowed();
}
return AccessResult::forbidden();
}