You are here

WebformSubmissionLogRouteSubscriber.php in Webform 6.x

File

modules/webform_submission_log/src/Routing/WebformSubmissionLogRouteSubscriber.php
View source
<?php

namespace Drupal\webform_submission_log\Routing;

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

/**
 * Remove webform node log routes.
 */
class WebformSubmissionLogRouteSubscriber extends RouteSubscriberBase {

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

  /**
   * Constructs a WebformSubmissionLogRouteSubscriber 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.results_log');
      $collection
        ->remove('entity.node.webform_submission.log');
    }
  }

}

Classes

Namesort descending Description
WebformSubmissionLogRouteSubscriber Remove webform node log routes.