RouteSubscriber.php 883 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. namespace Drupal\materio_user\Routing;
  3. use Drupal\Core\Routing\RouteSubscriberBase;
  4. use Symfony\Component\Routing\RouteCollection;
  5. /**
  6. * Listens to the dynamic route events.
  7. */
  8. class RouteSubscriber extends RouteSubscriberBase {
  9. /**
  10. * {@inheritdoc}
  11. */
  12. protected function alterRoutes(RouteCollection $collection) {
  13. // // Change path '/user/login' to '/login'.
  14. // if ($route = $collection->get('user.login')) {
  15. // $route->setPath('/login');
  16. // }
  17. // // Always deny access to '/user/logout'.
  18. // // Note that the second parameter of setRequirement() is a string.
  19. // if ($route = $collection->get('user.logout')) {
  20. // $route->setRequirement('_access', 'FALSE');
  21. // }
  22. // redirect /user/register to pricing
  23. if ($route = $collection->get('user.register')) {
  24. $route->setRequirement('_access', 'FALSE');
  25. }
  26. }
  27. }