You are here

class StyleguideRoutes in Style Guide 8

Same name and namespace in other branches
  1. 2.x src/StyleguideRoutes.php \Drupal\styleguide\StyleguideRoutes

The Styleguide routers.

Hierarchy

Expanded class hierarchy of StyleguideRoutes

1 string reference to 'StyleguideRoutes'
styleguide.services.yml in ./styleguide.services.yml
styleguide.services.yml
1 service uses StyleguideRoutes
styleguide.routes in ./styleguide.services.yml
Drupal\styleguide\StyleguideRoutes

File

src/StyleguideRoutes.php, line 13

Namespace

Drupal\styleguide
View source
class StyleguideRoutes implements ContainerInjectionInterface {

  /**
   * The theme handler service.
   *
   * @var \Drupal\Core\Extension\ThemeHandlerInterface
   */
  protected $themeHandler;

  /**
   * StyleguideRoutes constructor.
   *
   * @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
   *   The theme handler service.
   */
  public function __construct(ThemeHandlerInterface $theme_handler) {
    $this->themeHandler = $theme_handler;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    new static($container
      ->get('theme_handler'));
  }

  /**
   * {@inheritdoc}
   */
  public function routes() {
    $routes = [];
    $themes = $this->themeHandler
      ->rebuildThemeData();
    foreach ($themes as &$theme) {
      if (!empty($theme->info['hidden'])) {
        continue;
      }
      if ($theme->status) {
        $name = $theme
          ->getName();
        $routes['styleguide.' . $name] = new Route('/admin/appearance/styleguide/' . $name, [
          '_controller' => 'Drupal\\styleguide\\Controller\\StyleguideController::page',
          '_title' => $theme->info['name'],
        ], [
          '_permission' => 'view style guides',
        ], [
          '_admin_route' => FALSE,
        ]);
        $routes['styleguide.maintenance_page.' . $name] = new Route('/admin/appearance/styleguide/maintenance-page/' . $name, [
          '_controller' => 'Drupal\\styleguide\\Controller\\StyleguideMaintenancePageController::page',
          '_title' => $theme->info['name'],
        ], [
          '_permission' => 'view style guides',
        ], [
          '_admin_route' => FALSE,
        ]);
      }
    }
    return $routes;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StyleguideRoutes::$themeHandler protected property The theme handler service.
StyleguideRoutes::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
StyleguideRoutes::routes public function
StyleguideRoutes::__construct public function StyleguideRoutes constructor.