public function SocialTopicController::myTopicAccess in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 8.3 modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 8.5 modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 8.6 modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 8.7 modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 8.8 modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 10.3.x modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 10.0.x modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 10.1.x modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
- 10.2.x modules/social_features/social_topic/src/Controller/SocialTopicController.php \Drupal\social_topic\Controller\SocialTopicController::myTopicAccess()
Function that checks access on the my topic pages.
Parameters
\Drupal\Core\Session\AccountInterface $account: The account we need to check access for.
Return value
\Drupal\Core\Access\AccessResult If access is allowed.
File
- modules/
social_features/ social_topic/ src/ Controller/ SocialTopicController.php, line 105
Class
- SocialTopicController
- Returns responses for Social Topic routes.
Namespace
Drupal\social_topic\ControllerCode
public function myTopicAccess(AccountInterface $account) {
// Fetch user from url.
$user = $this->requestStack
->getCurrentRequest()
->get('user');
// If we don't have a user in the request, assume it's my own profile.
if (is_null($user)) {
// Usecase is the user menu, which is generated on all LU pages.
$user = User::load($account
->id());
}
// If not a user then just return neutral.
if (!$user instanceof User) {
$user = User::load($user);
if (!$user instanceof User) {
return AccessResult::neutral();
}
}
// Own profile?
if ($user
->id() === $account
->id()) {
return AccessResult::allowedIfHasPermission($account, 'view topics on my profile');
}
return AccessResult::allowedIfHasPermission($account, 'view topics on other profiles');
}