SocialGroupSecretSubscriber.php in Open Social 8.8
Same filename and directory in other branches
- 8.9 modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
- 8.6 modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
- 8.7 modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
- 10.3.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
- 10.0.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
- 10.1.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
- 10.2.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php
File
modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.phpView source
<?php
namespace Drupal\social_group_secret\EventSubscriber;
use Drupal\Core\EventSubscriber\HttpExceptionSubscriberBase;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\group\Entity\GroupInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class SocialGroupSecretSubscriber.
*
* @package Drupal\social_group_secret\EventSubscriber
*/
class SocialGroupSecretSubscriber extends HttpExceptionSubscriberBase {
/**
* The currently active route match object.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* Constructs a new SocialGroupSecretSubscriber.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The currently active route match object.
*/
public function __construct(RouteMatchInterface $route_match) {
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*/
protected function getHandledFormats() {
return [
'html',
];
}
/**
* {@inheritdoc}
*/
protected static function getPriority() {
// We need a higher priority than R4032Login so that it doesn't create a
// response to login.
return 100;
}
/**
* {@inheritdoc}
*/
public function on403(GetResponseEvent $event) {
$group = $this->routeMatch
->getParameter('group');
// Show 404 page instead of 403 page for secret groups.
if ($group instanceof GroupInterface && $group
->bundle() === 'secret_group') {
// Change the exception to show as 404 instead of 403.
$event
->setException(new NotFoundHttpException());
}
}
}
Classes
Name | Description |
---|---|
SocialGroupSecretSubscriber | Class SocialGroupSecretSubscriber. |