You are here

public function PhotosRearrangeController::access in Album Photos 8.4

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

A custom access check.

Parameters

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

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

File

src/Controller/PhotosRearrangeController.php, line 112

Class

PhotosRearrangeController
Re-arrange view controller.

Namespace

Drupal\photos\Controller

Code

public function access(AccountInterface $account) {

  // Check if user can edit this album.
  $node = $this->routeMatch
    ->getParameter('node');

  // Check user for album rearrange.
  $user = $this->routeMatch
    ->getParameter('user');
  if ($user && !is_object($user)) {
    $user = $this->entityTypeManager
      ->getStorage('user')
      ->load($user);
  }
  if ($node && _photos_access('editAlbum', $node)) {
    return AccessResult::allowed();
  }
  elseif ($user && _photos_access('viewUser', $user)) {
    return AccessResult::allowed();
  }
  else {
    return AccessResult::forbidden();
  }
}