You are here

class AppsPageAccessCheck in Apigee Edge 8

Custom access handler to Apps page.

Hierarchy

Expanded class hierarchy of AppsPageAccessCheck

1 file declares its use of AppsPageAccessCheck
DeveloperAppRouteProvider.php in src/Entity/DeveloperAppRouteProvider.php

File

src/Access/AppsPageAccessCheck.php, line 31

Namespace

Drupal\apigee_edge\Access
View source
class AppsPageAccessCheck implements AccessInterface {

  /**
   * Grant access to the Apps page if user has any of the required permissions.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The parametrized route.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(RouteMatchInterface $route_match, AccountInterface $account) {

    /** @var \Drupal\user\UserInterface $user */
    $user = $route_match
      ->getParameter('user');
    if ($user === NULL) {
      return AccessResult::forbidden('User is missing from route.');
    }
    return AccessResultAllowed::allowedIf($account
      ->id() === $user
      ->id() && $account
      ->hasPermission('view own developer_app') || $account
      ->hasPermission('administer developer_app'));
  }

  /**
   * Grant access to the user/[uid]/create-apps page.
   *
   * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
   *   The parametrized route.
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function createAppAccess(RouteMatchInterface $route_match, AccountInterface $account) {

    /** @var \Drupal\user\UserInterface $user */
    $user = $route_match
      ->getParameter('user');
    if ($user === NULL) {
      return AccessResult::forbidden('User is missing from route.');
    }
    return AccessResultAllowed::allowedIf($account
      ->id() === $user
      ->id() && $account
      ->hasPermission('create developer_app') || $account
      ->hasPermission('administer developer_app'));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AppsPageAccessCheck::access public function Grant access to the Apps page if user has any of the required permissions.
AppsPageAccessCheck::createAppAccess public function Grant access to the user/[uid]/create-apps page.