Added a commented out bit of code for automatic permissions

This commit is contained in:
Naomi 2018-10-26 11:23:21 +01:00
parent 142c22f8e2
commit acf3e704cc

View File

@ -6,6 +6,26 @@
*/ */
use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
/**
* When a new actor type is created, this gives the CRM Admin and Overseer roles permission
* to view, edit and delete them.
*/
#function opencase_defaults_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
# if (get_class($entity) == 'Drupal\opencase_entities\Entity\OCActorType') {
# $type = $entity->id();
# $roles = Role::loadMultiple(['opencase_admin', 'overseer']);
# foreach ($roles as $role) {
# $role->grantPermission("view published $type entities");
# $role->grantPermission("edit $type entities");
# $role->grantPermission("delete $type entities");
# $role->grantPermission("add new $type entities");
# }
# \Drupal::logger('foo')->notice("<pre>".print_r(user_role_permissions(['overseer']), true) . "</pre>");
# }
#}
/** /**
* Implements hook_help(). * Implements hook_help().