You are here

public function SocialCommentController::commentPermalink in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  2. 8.2 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  3. 8.3 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  4. 8.4 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  5. 8.5 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  6. 8.6 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  7. 8.7 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  8. 8.8 modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  9. 10.3.x modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  10. 10.0.x modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  11. 10.1.x modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()
  12. 10.2.x modules/social_features/social_comment/src/Controller/SocialCommentController.php \Drupal\social_comment\Controller\SocialCommentController::commentPermalink()

Redirects comment links to the correct page depending on permissions.

@inheritdoc

Overrides CommentController::commentPermalink

File

modules/social_features/social_comment/src/Controller/SocialCommentController.php, line 23

Class

SocialCommentController
Controller routine override to change relevant bits in the password reset.

Namespace

Drupal\social_comment\Controller

Code

public function commentPermalink(Request $request, CommentInterface $comment) {
  if ($entity = $comment
    ->getCommentedEntity()) {

    // Check access permissions for the entity.

    /* @var \Drupal\Core\Entity\Entity $entity */
    if (!$entity
      ->access('view')) {
      throw new AccessDeniedHttpException();
    }

    /* @var \Drupal\Core\Url $url */
    if ($url = $entity
      ->urlInfo('canonical')) {

      // Redirect the user to the correct entity.
      return $this
        ->redirectToOriginalEntity($url, $comment, $entity);
    }
  }
  throw new NotFoundHttpException();
}