You are here

class CustomAccessCheck in Entity connect 8.2

Custom access checking class for entityconnect.

Hierarchy

Expanded class hierarchy of CustomAccessCheck

1 string reference to 'CustomAccessCheck'
entityconnect.services.yml in ./entityconnect.services.yml
entityconnect.services.yml
1 service uses CustomAccessCheck
entityconnect.access_check in ./entityconnect.services.yml
Drupal\entityconnect\Access\CustomAccessCheck

File

src/Access/CustomAccessCheck.php, line 13

Namespace

Drupal\entityconnect\Access
View source
class CustomAccessCheck implements AccessCheckInterface {

  /**
   * {@inheritdoc}
   */
  public function applies(Route $route) {
    return $route
      ->hasRequirement('_entityconnect_access_check');
  }

  /**
   * A custom access check.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   Run access checks for this account.
   *
   * @return \Drupal\Core\Access\AccessResult
   *   If the account has the permissions, isAllowed() will be TRUE,
   *   otherwise isNeutral() will be TRUE.
   */
  public function access(AccountInterface $account) {

    // Check permissions and combine that with any custom access checking
    // needed. Pass forward parameters from the route and/or request as needed.
    return AccessResultAllowed::allowedIfHasPermissions($account, [
      'entityconnect add button',
      'entityconnect edit button',
    ], 'OR');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CustomAccessCheck::access public function A custom access check.
CustomAccessCheck::applies public function Declares whether the access check applies to a specific route or not. Overrides AccessCheckInterface::applies