MentionsController.php in Open Social 8.3
Same filename and directory in other branches
- 8.9 modules/custom/mentions/src/MentionsController.php
- 8 modules/custom/mentions/src/MentionsController.php
- 8.2 modules/custom/mentions/src/MentionsController.php
- 8.4 modules/custom/mentions/src/MentionsController.php
- 8.5 modules/custom/mentions/src/MentionsController.php
- 8.6 modules/custom/mentions/src/MentionsController.php
- 8.7 modules/custom/mentions/src/MentionsController.php
- 8.8 modules/custom/mentions/src/MentionsController.php
- 10.3.x modules/custom/mentions/src/MentionsController.php
- 10.0.x modules/custom/mentions/src/MentionsController.php
- 10.1.x modules/custom/mentions/src/MentionsController.php
- 10.2.x modules/custom/mentions/src/MentionsController.php
Namespace
Drupal\mentionsFile
modules/custom/mentions/src/MentionsController.phpView source
<?php
namespace Drupal\mentions;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Controller for the mentions entity.
*
* @see \Drupal\mention\Entity\Comment.
*/
class MentionsController extends ControllerBase {
/**
* Redirects mention links to the correct page depending on entity context.
*
* Taken from: commentPermalink.
*
* @param \Drupal\mentions\MentionsInterface $mentions
* A mention entity.
*
* @return \Symfony\Component\HttpFoundation\Response
* The mention listing set to the page on which the mention appears.
*
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
* @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
*/
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();
}
}
Classes
Name | Description |
---|---|
MentionsController | Controller for the mentions entity. |