class Redirect in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 8.2 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 8.3 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 8.4 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 8.5 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 8.6 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 8.7 modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 10.0.x modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
- 10.1.x modules/custom/social_gdpr/src/Subscriber/Redirect.php \Drupal\social_gdpr\Subscriber\Redirect
Class Redirect.
@package Drupal\social_gdpr\Subscriber
Hierarchy
- class \Drupal\social_gdpr\Subscriber\Redirect implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of Redirect
1 string reference to 'Redirect'
- social_gdpr.services.yml in modules/
custom/ social_gdpr/ social_gdpr.services.yml - modules/custom/social_gdpr/social_gdpr.services.yml
1 service uses Redirect
- social_gdpr.redirect_subscriber in modules/
custom/ social_gdpr/ social_gdpr.services.yml - Drupal\social_gdpr\Subscriber\Redirect
File
- modules/
custom/ social_gdpr/ src/ Subscriber/ Redirect.php, line 18
Namespace
Drupal\social_gdpr\SubscriberView source
class Redirect implements EventSubscriberInterface {
/**
* The current active route match object.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
protected $routeMatch;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxyInterface
*/
protected $currentUser;
/**
* RedirectSubscriber constructor.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current active route match object.
* @param \Drupal\Core\Session\AccountProxyInterface $current_user
* The current user.
*/
public function __construct(RouteMatchInterface $route_match, AccountProxyInterface $current_user) {
$this->routeMatch = $route_match;
$this->currentUser = $current_user;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'checkForRedirection',
];
return $events;
}
/**
* This method is called when the KernelEvents::REQUEST event is dispatched.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event.
*/
public function checkForRedirection(GetResponseEvent $event) {
if ($this->routeMatch
->getRouteName() != 'entity.data_policy.version_history') {
return;
}
if ($this->currentUser
->id() == 1 || !$this->currentUser
->hasPermission('view all data policy revisions')) {
return;
}
$url = Url::fromRoute('social_gdpr.data_policy.revisions');
$response = new RedirectResponse($url
->toString());
$event
->setResponse($response);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Redirect:: |
protected | property | The current user. | |
Redirect:: |
protected | property | The current active route match object. | |
Redirect:: |
public | function | This method is called when the KernelEvents::REQUEST event is dispatched. | |
Redirect:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
Redirect:: |
public | function | RedirectSubscriber constructor. |