public function PhotosRearrangeController::access in Album Photos 8.5
Same name and namespace in other branches
- 8.4 src/Controller/PhotosRearrangeController.php \Drupal\photos\Controller\PhotosRearrangeController::access()
- 6.0.x src/Controller/PhotosRearrangeController.php \Drupal\photos\Controller\PhotosRearrangeController::access()
A custom access check.
Parameters
\Drupal\Core\Session\AccountInterface $account: The current user.
\Drupal\node\NodeInterface $node: The album node entity.
\Drupal\user\Entity\User $user: The user account being viewed.
Return value
\Drupal\Core\Access\AccessResult The access result.
1 string reference to 'PhotosRearrangeController::access'
File
- src/
Controller/ PhotosRearrangeController.php, line 124
Class
- PhotosRearrangeController
- Re-arrange view controller.
Namespace
Drupal\photos\ControllerCode
public function access(AccountInterface $account = NULL, NodeInterface $node = NULL, User $user = NULL) {
// Check if user can rearrange this album.
if ($node && $node
->access('update')) {
if ($node
->getType() == 'photos') {
return AccessResult::allowed();
}
// Prevent rearrange tab from showing on other node types.
return AccessResult::forbidden();
}
elseif ($account && $user && ($account
->id() && $account
->hasPermission('create photo') || $account
->hasPermission('access user profiles') && $account
->hasPermission('view photo')) && ($user
->id() == $account
->id() || $account
->hasPermission('administer users'))) {
return AccessResult::allowed();
}
else {
return AccessResult::forbidden();
}
}