class RedirectSubscriber in Open Social 10.3.x
Same name in this branch
- 10.3.x modules/social_features/social_search/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_search\EventSubscriber\RedirectSubscriber
- 10.3.x modules/social_features/social_group/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group\EventSubscriber\RedirectSubscriber
- 10.3.x modules/social_features/social_user/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_user\EventSubscriber\RedirectSubscriber
- 10.3.x modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 10.3.x modules/social_features/social_group/modules/social_group_default_route/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_default_route\EventSubscriber\RedirectSubscriber
- 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_flexible_group\EventSubscriber\RedirectSubscriber
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 8.4 modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 8.5 modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 8.6 modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 8.7 modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 8.8 modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 10.0.x modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 10.1.x modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
- 10.2.x modules/social_features/social_group/modules/social_group_quickjoin/src/EventSubscriber/RedirectSubscriber.php \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
Class RedirectSubscriber.
@package Drupal\social_group_quickjoin\EventSubscriber
Hierarchy
- class \Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of RedirectSubscriber
1 string reference to 'RedirectSubscriber'
- social_group_quickjoin.services.yml in modules/
social_features/ social_group/ modules/ social_group_quickjoin/ social_group_quickjoin.services.yml - modules/social_features/social_group/modules/social_group_quickjoin/social_group_quickjoin.services.yml
1 service uses RedirectSubscriber
- social_group_quickjoin.redirect_subscriber in modules/
social_features/ social_group/ modules/ social_group_quickjoin/ social_group_quickjoin.services.yml - Drupal\social_group_quickjoin\EventSubscriber\RedirectSubscriber
File
- modules/
social_features/ social_group/ modules/ social_group_quickjoin/ src/ EventSubscriber/ RedirectSubscriber.php, line 20
Namespace
Drupal\social_group_quickjoin\EventSubscriberView source
class RedirectSubscriber implements EventSubscriberInterface {
/**
* The current route.
*
* @var \Drupal\Core\Routing\CurrentRouteMatch
*/
protected $currentRoute;
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountProxy
*/
protected $currentUser;
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* Redirectsubscriber construct.
*
* @param \Drupal\Core\Routing\CurrentRouteMatch $route_match
* The current route.
* @param \Drupal\Core\Session\AccountProxy $current_user
* The current user.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configfactory.
*/
public function __construct(CurrentRouteMatch $route_match, AccountProxy $current_user, ConfigFactoryInterface $config_factory) {
$this->currentRoute = $route_match;
$this->currentUser = $current_user;
$this->configFactory = $config_factory;
}
/**
* Get the request events.
*
* @return mixed
* Returns request events.
*/
public static function getSubscribedEvents() {
$events[KernelEvents::REQUEST][] = [
'groupQuickJoin',
];
return $events;
}
/**
* This method is called when the KernelEvents::REQUEST event is dispatched.
*
* @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
* The event.
*/
public function groupQuickJoin(GetResponseEvent $event) {
// First check if the current route is the group canonical.
$routeMatch = $this->currentRoute
->getRouteName();
// Not group canonical, then we leave.
if ($routeMatch != 'entity.group.join') {
return;
}
// Fetch the group parameter and check if's an actual group.
$group = $this->currentRoute
->getParameter('group');
// Not group, then we leave.
if (!$group instanceof Group) {
return;
}
// Fetch the settings.
$settings = $this->configFactory
->get('social_group_quickjoin.settings');
// Check if the feature enabled.
if ($settings
->get('social_group_quickjoin_enabled') == FALSE) {
return;
}
// Check if the current group type is enabled.
if ($settings
->get('social_group_quickjoin_' . $group
->getGroupType()
->id()) == FALSE) {
return;
}
// Create quickjoin URL from route.
$url = Url::fromRoute('social_group_quickjoin.quickjoin_group', [
'group' => $group
->id(),
])
->toString();
// Redirect to quickjoin.
$event
->setResponse(new RedirectResponse($url));
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RedirectSubscriber:: |
protected | property | The config factory. | |
RedirectSubscriber:: |
protected | property | The current route. | |
RedirectSubscriber:: |
protected | property | The current user. | |
RedirectSubscriber:: |
public static | function | Get the request events. | |
RedirectSubscriber:: |
public | function | This method is called when the KernelEvents::REQUEST event is dispatched. | |
RedirectSubscriber:: |
public | function | Redirectsubscriber construct. |