You are here

public function PhotosAlbumController::access in Album Photos 8.4

Same name and namespace in other branches
  1. 8.5 src/Controller/PhotosAlbumController.php \Drupal\photos\Controller\PhotosAlbumController::access()
  2. 6.0.x src/Controller/PhotosAlbumController.php \Drupal\photos\Controller\PhotosAlbumController::access()

A custom access check.

Parameters

\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.

1 string reference to 'PhotosAlbumController::access'
photos.routing.yml in ./photos.routing.yml
photos.routing.yml

File

src/Controller/PhotosAlbumController.php, line 125

Class

PhotosAlbumController
Album view controller.

Namespace

Drupal\photos\Controller

Code

public function access(AccountInterface $account) {

  // Get node.
  $node = $this->routeMatch
    ->getParameter('node');
  if (!$node) {

    // Not found.
    throw new NotFoundHttpException();
  }

  // Check access.
  $access_op = 'album';
  if ($account
    ->hasPermission('view photo') && _photos_access($access_op, $node)) {

    // Allow access.
    return AccessResult::allowed();
  }
  else {
    return AccessResult::forbidden();
  }
}