public static AccessResult::allowedIfHasPermission(AccountInterface $account, $permission)
Creates an allowed access result if the permission is present, neutral otherwise.
Checks the permission and adds a 'user.permissions' cache context.
\Drupal\Core\Session\AccountInterface $account: The account for which to check a permission.
string $permission: The permission to check for.
\Drupal\Core\Access\AccessResult If the account has the permission, isAllowed() will be TRUE, otherwise isNeutral() will be TRUE.
public static function allowedIfHasPermission(AccountInterface $account, $permission) { return static::allowedIf($account->hasPermission($permission))->addCacheContexts(['user.permissions']); }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Access!AccessResult.php/function/AccessResult::allowedIfHasPermission/8.1.x