You are here

public function AccessDenied::actionAccess in Flag 8.4

Checks whether a user has permission to flag/unflag or not.

Parameters

string $action: The action for which to check permissions, either 'flag' or 'unflag'.

\Drupal\flag\FlagInterface $flag: The flag object.

\Drupal\Core\Session\AccountInterface $account: An AccountInterface object.

\Drupal\Core\Entity\EntityInterface $flaggable: (optional) The flaggable entity.

Return value

\Drupal\Core\Access\AccessResult An AccessResult object.

Overrides EntityFlagType::actionAccess

File

tests/modules/flag_test_plugins/src/Plugin/Flag/AccessDenied.php, line 25

Class

AccessDenied
Test flag type plugin which denies access.

Namespace

Drupal\flag_test_plugins\Plugin\Flag

Code

public function actionAccess($action, FlagInterface $flag, AccountInterface $account, EntityInterface $flaggable = NULL) {
  if (empty($flaggable)) {

    // Grant access if the method is called with no flaggable parameter. This
    // is to ensure that access in the code being tested is properly passing
    // the flaggable entity and not only relying on the general access case.
    return AccessResult::allowed();
  }
  else {
    return AccessResult::forbidden();
  }
}