public function RouteSubscriber::alterRoutes in Forum Access 8
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- src/
Routing/ RouteSubscriber.php, line 16
Class
- RouteSubscriber
- Listens to the dynamic route events.
Namespace
Drupal\forum_access\RoutingCode
public function alterRoutes(RouteCollection $collection) {
// Check access to the index forum page.
if ($route = $collection
->get('forum.index')) {
// @todo Check if we can save previous custom access without rewrite.
$route
->setRequirement('_custom_access', '\\Drupal\\forum_access\\ForumAccess\\Access::forumIndex');
}
// Check Access for the specific forum.
if ($route = $collection
->get('forum.page')) {
$route
->setRequirement('_custom_access', '\\Drupal\\forum_access\\ForumAccess\\Access::forumPage');
}
// Access for comment reply according to the taxonomy term of forum.
if ($route = $collection
->get('comment.reply')) {
$route
->setRequirement('_custom_access', '\\Drupal\\forum_access\\ForumAccess\\Access::commentReply');
}
}