You are here

public function BakeryRoutes::routes in Bakery Single Sign-On System 8.2

1 string reference to 'BakeryRoutes::routes'
bakery.routing.yml in ./bakery.routing.yml
bakery.routing.yml

File

src/Routing/BakeryRoutes.php, line 36

Class

BakeryRoutes
Defines dynamic routes.

Namespace

Drupal\bakery\Routing

Code

public function routes() {
  $routes = new RouteCollection();
  $subsite_login = $this->config
    ->get('subsite_login');
  if (empty($this->config
    ->get('bakery_key'))) {

    // Without a key nothing works so don't expose any dynamic routes.
  }
  elseif ($this->config
    ->get('bakery_is_master')) {
    if ($subsite_login) {
      $routes
        ->add('bakery.register', new Route('/bakery', [
        '_controller' => '\\Drupal\\bakery\\Controller\\MainDeprecatedController::register',
        '_title' => 'Register',
      ], [
        '_custom_access' => '\\Drupal\\bakery\\Controller\\MainDeprecatedController::userIsAnonymous',
      ]));
      $routes
        ->add('bakery.login', new Route('/bakery/login', [
        '_controller' => '\\Drupal\\bakery\\Controller\\MainDeprecatedController::login',
        '_title' => 'Login',
      ], [
        '_access' => 'TRUE',
      ]));
    }
    $routes
      ->add('bakery.create', new Route('/bakery/create', [
      '_controller' => '\\Drupal\\bakery\\Controller\\MainController::eatGingerbreadCookie',
      '_title' => 'Bakery create',
    ], [
      '_custom_access' => '\\Drupal\\bakery\\Controller\\MainController::tasteGingerbreadCookie',
    ]));
  }
  else {
    if ($subsite_login) {
      $routes
        ->add('bakery.register', new Route('/bakery', [
        '_controller' => '\\Drupal\\bakery\\Controller\\ChildDeprecatedController::registerReturn',
        '_title' => 'Register',
      ], [
        '_access' => 'TRUE',
      ]));
      $routes
        ->add('bakery.create', new Route('/bakery/login', [
        '_controller' => '\\Drupal\\bakery\\Controller\\ChildDeprecatedController::loginReturn',
        '_title' => 'Login',
      ], [
        '_access' => 'TRUE',
      ]));
    }
    $routes
      ->add('bakery.update', new Route('/bakery/update', [
      '_controller' => '\\Drupal\\bakery\\Controller\\ChildController::eatStroopwafelCookie',
      '_title' => 'Update',
    ], [
      '_custom_access' => '\\Drupal\\bakery\\Controller\\ChildController::tasteStroopwafelCookie',
    ]));
    $routes
      ->add('bakery.repair', new Route('/bakery/repair', [
      '_form' => '\\Drupal\\bakery\\Forms\\BakeryUncrumbleForm',
      '_title' => 'Repair account',
    ], [
      '_custom_access' => '\\Drupal\\bakery\\Forms\\BakeryUncrumbleForm::uncrumbleAccess',
    ]));
    $routes
      ->add('bakery.pull', new Route('/admin/config/people/bakery', [
      '_form' => '\\Drupal\\bakery\\Forms\\BakeryPullForm',
      '_title' => 'Pull Bakery user',
    ], [
      '_permission' => 'administer users',
    ]));
  }
  $routes
    ->addOptions([
    'compiler_class' => RouteCompiler::class,
  ]);
  return $routes;
}