public function PhotosAlbumController::access in Album Photos 8.5
Same name and namespace in other branches
- 8.4 src/Controller/PhotosAlbumController.php \Drupal\photos\Controller\PhotosAlbumController::access()
- 6.0.x 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\ControllerCode
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();
}
}