You are here

public function MentionsController::mentionPermalink in Open Social 8.7

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

Redirects mention links to the correct page depending on entity context.

Taken from: commentPermalink.

Parameters

\Drupal\mentions\MentionsInterface $mentions: A mention entity.

Return value

\Symfony\Component\HttpFoundation\Response The mention listing set to the page on which the mention appears.

Throws

\Symfony\Component\HttpKernel\Exception\NotFoundHttpException

\Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

1 string reference to 'MentionsController::mentionPermalink'
mentions.routing.yml in modules/custom/mentions/mentions.routing.yml
modules/custom/mentions/mentions.routing.yml

File

modules/custom/mentions/src/MentionsController.php, line 31

Class

MentionsController
Controller for the mentions entity.

Namespace

Drupal\mentions

Code

public function mentionPermalink(MentionsInterface $mentions) {
  if ($entity = $mentions
    ->getMentionedEntity()) {

    // Check access permissions for the entity.
    if (!$entity
      ->access('view')) {
      throw new AccessDeniedHttpException();
    }
    $entity_url = $entity
      ->toUrl('canonical');
    return new RedirectResponse($entity_url
      ->setAbsolute()
      ->toString());
  }
  throw new NotFoundHttpException();
}