You are here

WebformCardsRouteSubscriber.php in Webform 6.x

Same filename and directory in other branches
  1. 8.5 modules/webform_cards/src/Routing/WebformCardsRouteSubscriber.php

File

modules/webform_cards/src/Routing/WebformCardsRouteSubscriber.php
View source
<?php

namespace Drupal\webform_cards\Routing;

use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;

/**
 * Remove webform cards routes.
 */
class WebformCardsRouteSubscriber extends RouteSubscriberBase {

  /**
   * The module handler.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs a WebformCardsRouteSubscriber object.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler.
   */
  public function __construct(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
  }

  /**
   * {@inheritdoc}
   */
  protected function alterRoutes(RouteCollection $collection) {
    if (!$this->moduleHandler
      ->moduleExists('webform_ui')) {
      $collection
        ->remove('entity.webform_ui.element.add_card');
    }
  }

}

Classes

Namesort descending Description
WebformCardsRouteSubscriber Remove webform cards routes.