You are here

public function SiteVerifyRoutes::routes in Site verification 8

1 string reference to 'SiteVerifyRoutes::routes'
site_verify.routing.yml in ./site_verify.routing.yml
site_verify.routing.yml

File

src/Routing/SiteVerifyRoutes.php, line 16

Class

SiteVerifyRoutes
Defines dynamic routes.

Namespace

Drupal\site_verify\Routing

Code

public function routes() {
  $verifications = \Drupal::database()
    ->select('site_verify', 'site_verify')
    ->fields('site_verify', [
    'svid',
    'file',
  ])
    ->condition('file', '', '<>')
    ->execute()
    ->fetchAll();
  $route_collection = new RouteCollection();
  foreach ($verifications as $verification) {
    $route = new Route($verification->file, [
      '_controller' => '\\Drupal\\site_verify\\Controller\\SiteVerifyController::verificationsFileContent',
      'svid' => $verification->svid,
    ], [
      '_access' => 'TRUE',
    ]);
    $route_collection
      ->add('site_verify.' . $verification->file, $route);
  }
  return $route_collection;
}