<?php

namespace Drupal\materio_user\Routing;

use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Listens to the dynamic route events.
 */
class RouteSubscriber extends RouteSubscriberBase {

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    // // Change path '/user/login' to '/login'.
    // if ($route = $collection->get('user.login')) {
    //   $route->setPath('/login');
    // }
    // // Always deny access to '/user/logout'.
    // // Note that the second parameter of setRequirement() is a string.
    // if ($route = $collection->get('user.logout')) {
    //   $route->setRequirement('_access', 'FALSE');
    // }

    // redirect /user/register to pricing
    if ($route = $collection->get('user.register')) {
      $route->setRequirement('_access', 'FALSE');
    }
  }

}
