protected function Route::alterRoutes in Open Social 8.6
Same name in this branch
- 8.6 modules/custom/social_gdpr/src/Subscriber/Route.php \Drupal\social_gdpr\Subscriber\Route::alterRoutes()
- 8.6 modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
- 8.7 modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
- 8.8 modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
- 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
- 10.0.x modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
- 10.1.x modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
- 10.2.x modules/social_features/social_group/modules/social_group_flexible_group/src/Subscriber/Route.php \Drupal\social_group_flexible_group\Subscriber\Route::alterRoutes()
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- modules/
social_features/ social_group/ modules/ social_group_flexible_group/ src/ Subscriber/ Route.php, line 18
Class
- Route
- Class Route.
Namespace
Drupal\social_group_flexible_group\SubscriberCode
protected function alterRoutes(RouteCollection $collection) {
// We define our routes and how they are impacted.
// is it on content visibility or join method.
$join_routes = [
'view.group_manage_members.page_group_manage_members' => 'join direct',
'entity.group_content.add_form' => 'join added',
];
foreach ($join_routes as $name => $argument) {
if ($route = $collection
->get($name)) {
$current = $route
->getRequirements();
$requirements = array_merge($current, [
'_flexible_group_join_permission' => $argument,
]);
$route
->addRequirements($requirements);
}
}
// Based on content visibility some routes need access.
// The argument is there for a minimum content visibility.
$content_routes = [
'entity.group.canonical',
'view.group_information.page_group_about',
'view.group_members.page_group_members',
'social_group.stream',
'view.group_events.page_group_events',
'view.group_topics.page_group_topics',
];
// Invoke implementations of
// hook_social_group_flexible_group_content_routes_alter().
// This to ensure extensions can also add their content tabs.
\Drupal::moduleHandler()
->alter('social_group_flexible_group_content_routes', $content_routes);
foreach ($content_routes as $name) {
if ($route = $collection
->get($name)) {
$current = $route
->getRequirements();
$requirements = array_merge($current, [
'_flexible_group_content_visibility' => 'public',
]);
$route
->addRequirements($requirements);
}
}
}