You are here

public function Fz152Routes::routes in FZ152 8

1 string reference to 'Fz152Routes::routes'
fz152.routing.yml in ./fz152.routing.yml
fz152.routing.yml

File

src/Routing/Fz152Routes.php, line 15

Class

Fz152Routes
Defines dynamic routes.

Namespace

Drupal\fz152\Routing

Code

public function routes() {
  $routes = [];
  $plugin_service = \Drupal::service('plugin.manager.fz152');
  foreach ($plugin_service
    ->getDefinitions() as $plugin_id => $plugin) {
    $instance = $plugin_service
      ->createInstance($plugin_id);
    $route_info = $instance
      ->getSettingsPage();
    if (!empty($route_info)) {
      $routes['fz152.settings.' . $plugin_id] = new Route('/admin/config/system/fz152/' . $route_info['path'], [
        '_form' => $route_info['form'],
        '_title' => $route_info['title'],
      ], [
        '_permission' => 'administer fz152',
      ]);
    }
  }
  return $routes;
}