You are here

class SocialGroupSecretSubscriber in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber
  2. 8.6 modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber
  3. 8.8 modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber
  4. 10.3.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber
  5. 10.0.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber
  6. 10.1.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber
  7. 10.2.x modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php \Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber

Class SocialGroupSecretSubscriber.

@package Drupal\social_group_secret\EventSubscriber

Hierarchy

Expanded class hierarchy of SocialGroupSecretSubscriber

1 string reference to 'SocialGroupSecretSubscriber'
social_group_secret.services.yml in modules/social_features/social_group/modules/social_group_secret/social_group_secret.services.yml
modules/social_features/social_group/modules/social_group_secret/social_group_secret.services.yml
1 service uses SocialGroupSecretSubscriber
social_group_secret.subscriber in modules/social_features/social_group/modules/social_group_secret/social_group_secret.services.yml
Drupal\social_group_secret\EventSubscriber\SocialGroupSecretSubscriber

File

modules/social_features/social_group/modules/social_group_secret/src/EventSubscriber/SocialGroupSecretSubscriber.php, line 16

Namespace

Drupal\social_group_secret\EventSubscriber
View source
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());
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HttpExceptionSubscriberBase::getSubscribedEvents public static function Registers the methods in this class that should be listeners.
HttpExceptionSubscriberBase::onException public function Handles errors for this subscriber.
SocialGroupSecretSubscriber::$routeMatch protected property The currently active route match object.
SocialGroupSecretSubscriber::getHandledFormats protected function Specifies the request formats this subscriber will respond to. Overrides HttpExceptionSubscriberBase::getHandledFormats
SocialGroupSecretSubscriber::getPriority protected static function Specifies the priority of all listeners in this class. Overrides HttpExceptionSubscriberBase::getPriority
SocialGroupSecretSubscriber::on403 public function
SocialGroupSecretSubscriber::__construct public function Constructs a new SocialGroupSecretSubscriber.