public function SocialAlbumController::checkAddImageAccess in Open Social 10.3.x
Same name and namespace in other branches
- 10.0.x modules/social_features/social_album/src/Controller/SocialAlbumController.php \Drupal\social_album\Controller\SocialAlbumController::checkAddImageAccess()
- 10.1.x modules/social_features/social_album/src/Controller/SocialAlbumController.php \Drupal\social_album\Controller\SocialAlbumController::checkAddImageAccess()
- 10.2.x modules/social_features/social_album/src/Controller/SocialAlbumController.php \Drupal\social_album\Controller\SocialAlbumController::checkAddImageAccess()
Checks access to the page for adding an image to an album.
Parameters
\Drupal\node\NodeInterface $node: The node entity object.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
1 string reference to 'SocialAlbumController::checkAddImageAccess'
- social_album.routing.yml in modules/
social_features/ social_album/ social_album.routing.yml - modules/social_features/social_album/social_album.routing.yml
File
- modules/
social_features/ social_album/ src/ Controller/ SocialAlbumController.php, line 205
Class
- SocialAlbumController
- Returns responses for Album routes.
Namespace
Drupal\social_album\ControllerCode
public function checkAddImageAccess(NodeInterface $node) {
if ($this
->checkAlbumAccess($node)) {
$account = $this
->currentUser();
if ($node
->getOwnerId() === $account
->id()) {
return AccessResult::allowed();
}
elseif (!$node->field_album_creators
->isEmpty() && $node->field_album_creators->value) {
/** @var \Drupal\group\Entity\Storage\GroupContentStorageInterface $storage */
$storage = $this
->entityTypeManager()
->getStorage('group_content');
if ($group_content = $storage
->loadByEntity($node)) {
/** @var \Drupal\group\Entity\GroupInterface $group */
$group = reset($group_content)
->getGroup();
return AccessResult::allowedIf($group
->getMember($account) !== FALSE);
}
}
}
return AccessResult::forbidden();
}