You are here

class WebformShareRouteSubscriber in Webform 8.5

Same name and namespace in other branches
  1. 6.x modules/webform_share/src/Routing/WebformShareRouteSubscriber.php \Drupal\webform_share\Routing\WebformShareRouteSubscriber

Remove webform share routes.

Hierarchy

Expanded class hierarchy of WebformShareRouteSubscriber

1 string reference to 'WebformShareRouteSubscriber'
webform_share.services.yml in modules/webform_share/webform_share.services.yml
modules/webform_share/webform_share.services.yml
1 service uses WebformShareRouteSubscriber
webform_share.route_subscriber in modules/webform_share/webform_share.services.yml
Drupal\webform_share\Routing\WebformShareRouteSubscriber

File

modules/webform_share/src/Routing/WebformShareRouteSubscriber.php, line 12

Namespace

Drupal\webform_share\Routing
View source
class WebformShareRouteSubscriber extends RouteSubscriberBase {

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

  /**
   * Constructs a WebformShareRouteSubscriber 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_node')) {
      $collection
        ->remove('entity.node.webform.share_embed');
      $collection
        ->remove('entity.node.webform.share_preview');
      $collection
        ->remove('entity.node.webform.share_test');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteSubscriberBase::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to. 5
RouteSubscriberBase::onAlterRoutes public function Delegates the route altering to self::alterRoutes(). 1
WebformShareRouteSubscriber::$moduleHandler protected property The module handler.
WebformShareRouteSubscriber::alterRoutes protected function Alters existing routes for a specific collection. Overrides RouteSubscriberBase::alterRoutes
WebformShareRouteSubscriber::__construct public function Constructs a WebformShareRouteSubscriber object.