function DevelGenerateRoutes::routes

Same name in other branches
  1. 8.x-1.x devel_generate/src/Routing/DevelGenerateRoutes.php \Drupal\devel_generate\Routing\DevelGenerateRoutes::routes()
  2. 5.x devel_generate/src/Routing/DevelGenerateRoutes.php \Drupal\devel_generate\Routing\DevelGenerateRoutes::routes()

Define routes for all devel_generate plugins.

1 string reference to 'DevelGenerateRoutes::routes'
devel_generate.routing.yml in devel_generate/devel_generate.routing.yml
devel_generate/devel_generate.routing.yml

File

devel_generate/src/Routing/DevelGenerateRoutes.php, line 37

Class

DevelGenerateRoutes
Provides dynamic routes for devel_generate.

Namespace

Drupal\devel_generate\Routing

Code

public function routes() {
    $devel_generate_plugins = $this->DevelGenerateManager
        ->getDefinitions();
    $routes = [];
    foreach ($devel_generate_plugins as $id => $plugin) {
        $label = $plugin['label'];
        $type_url_str = str_replace('_', '-', $plugin['url']);
        $routes["devel_generate.{$id}"] = new Route("admin/config/development/generate/{$type_url_str}", [
            '_form' => '\\Drupal\\devel_generate\\Form\\DevelGenerateForm',
            '_title' => "Generate {$label}",
            '_plugin_id' => $id,
        ], [
            '_permission' => $plugin['permission'],
        ]);
    }
    // Add the route for the 'Generate' admin group on the admin/config page.
    // This also provides the page for all devel_generate links.
    $routes['devel_generate.admin_config_generate'] = new Route('/admin/config/development/generate', [
        '_controller' => '\\Drupal\\system\\Controller\\SystemController::systemAdminMenuBlockPage',
        '_title' => 'Generate',
    ], [
        '_permission' => 'administer devel_generate',
    ]);
    return $routes;
}