You are here

public function PhotosAlbumController::access in Album Photos 6.0.x

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

A custom access check.

Parameters

\Drupal\Core\Session\AccountInterface $account: The current user.

\Drupal\node\NodeInterface $node: The album node entity.

Return value

\Drupal\Core\Access\AccessResult The access result.

File

src/Controller/PhotosAlbumController.php, line 155

Class

PhotosAlbumController
Album view controller.

Namespace

Drupal\photos\Controller

Code

public function access(AccountInterface $account, NodeInterface $node) {
  if (!$node) {

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

  // Check access.
  if ($account
    ->hasPermission('view photo') && $node
    ->access('view')) {

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