You are here

class DevelGenerateRoutes in Devel 8

Same name and namespace in other branches
  1. 8.3 devel_generate/src/Routing/DevelGenerateRoutes.php \Drupal\devel_generate\Routing\DevelGenerateRoutes
  2. 8.2 devel_generate/src/Routing/DevelGenerateRoutes.php \Drupal\devel_generate\Routing\DevelGenerateRoutes
  3. 4.x devel_generate/src/Routing/DevelGenerateRoutes.php \Drupal\devel_generate\Routing\DevelGenerateRoutes

Provides dynamic routes for devel_generate.

Hierarchy

Expanded class hierarchy of DevelGenerateRoutes

File

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

Namespace

Drupal\devel_generate\Routing
View source
class DevelGenerateRoutes implements ContainerInjectionInterface {

  /**
   * Constructs a new devel_generate route subscriber.
   *
   * @param \Drupal\Component\Plugin\PluginManagerInterface $devel_generate_manager
   *   The DevelGeneratePluginManager.
   */
  public function __construct(PluginManagerInterface $devel_generate_manager) {
    $this->DevelGenerateManager = $devel_generate_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('plugin.manager.develgenerate'));
  }
  public function routes() {
    $devel_generate_plugins = $this->DevelGenerateManager
      ->getDefinitions();
    $routes = array();
    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}", array(
        '_form' => '\\Drupal\\devel_generate\\Form\\DevelGenerateForm',
        '_title' => "Generate {$label}",
        '_plugin_id' => $id,
      ), array(
        '_permission' => $plugin['permission'],
      ));
    }
    return $routes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DevelGenerateRoutes::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
DevelGenerateRoutes::routes public function
DevelGenerateRoutes::__construct public function Constructs a new devel_generate route subscriber.