You are here

protected function GroupContentEnablerBase::updateAccess in Group 8

Performs access check for the update operation.

This method is supposed to be overwritten by extending classes that do their own custom access checking.

Parameters

\Drupal\group\Entity\GroupContentInterface $group_content: The group content for which to check access.

\Drupal\Core\Session\AccountInterface $account: The user for which to check access.

Return value

\Drupal\Core\Access\AccessResultInterface The access result.

1 call to GroupContentEnablerBase::updateAccess()
GroupContentEnablerBase::checkAccess in src/Plugin/GroupContentEnablerBase.php
Checks access to an operation on a given group content entity.

File

src/Plugin/GroupContentEnablerBase.php, line 347

Class

GroupContentEnablerBase
Provides a base class for GroupContentEnabler plugins.

Namespace

Drupal\group\Plugin

Code

protected function updateAccess(GroupContentInterface $group_content, AccountInterface $account) {
  $group = $group_content
    ->getGroup();
  $plugin_id = $this
    ->getPluginId();

  // Allow members to edit their own group content.
  if ($group_content
    ->getOwnerId() == $account
    ->id()) {
    return GroupAccessResult::allowedIfHasGroupPermission($group, $account, "update own {$plugin_id} content");
  }
  return GroupAccessResult::allowedIfHasGroupPermission($group, $account, "update any {$plugin_id} content");
}