Skip to content

Commit

Permalink
OI-74: Implemented hook_entity_access instead of changing access hand…
Browse files Browse the repository at this point in the history
…ler.
  • Loading branch information
nvelychenko committed Jul 24, 2020
1 parent abe9994 commit b334ec4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 34 deletions.
12 changes: 7 additions & 5 deletions modules/openideal_idea/openideal_idea.module
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use Drupal\Core\Url;
use Drupal\node\NodeInterface;
use Drupal\openideal_idea\ComputedNumberList;
use Drupal\openideal_idea\Form\OpenidealBaseRatingForm;
use Drupal\openideal_idea\Plugin\OpenidealGroupContentAccessControlHandler as GroupContentAccessHandle;

/**
* Implements hook_theme().
Expand Down Expand Up @@ -287,9 +286,12 @@ function openideal_idea_entity_type_build(array &$entity_types) {
}

/**
* Implements hook_group_content_info_alter().
* Implements hook_ENTITY_TYPE_access().
*/
function openideal_idea_group_content_info_alter(&$info) {
// Alter the content enabler plugin definitions to use our class.
$info['group_membership']['handlers']['access'] = GroupContentAccessHandle::class;
function openideal_idea_group_content_access(EntityInterface $entity, $operation, AccountInterface $account) {
if ($entity->getOwnerId() === $account->id()
&& $operation == 'delete'
&& $entity->getContentPlugin()->getPluginId() == 'group_membership') {
return AccessResult::forbidden();
}
}

This file was deleted.

0 comments on commit b334ec4

Please sign in to comment.