Commit fd2738a4 authored by Wesley Sandra's avatar Wesley Sandra Committed by Marcelo Vani
Browse files

Issue #3317370 by weseze: Remove (undefined) dependency on the help module

parent 1f9dda1c
Loading
Loading
Loading
Loading
+42 −13
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Url;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
@@ -13,6 +14,32 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
 */
class ConfigTokensForm extends ConfigFormBase {

  /**
   * Module Handler service object.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructor for Config Tokens.
   *
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   Module Handler service object.
   */
  public function __construct(ModuleHandlerInterface $module_handler) {
    $this->moduleHandler = $module_handler;
  }

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

  /**
   * {@inheritdoc}
   */
@@ -96,12 +123,13 @@ class ConfigTokensForm extends ConfigFormBase {
      }
    }

    if ($this->moduleHandler->moduleExists('help')) {
      $markup = '<p>' . t('See the list of <a href=":field#token-config-token" target="_blank">available tokens</a>. For more information, see the <a href=":docs" target="_blank">online documentation.</a></p>',
        [
          ':field' => Url::fromRoute('help.page', ['name' => 'token'])->toString(),
          ':docs' => Url::fromRoute('help.page', ['name' => 'config_token'])->toString()
      ]);

        ]
      );

      $form['values'][]['help'] = array(
        '#markup' => $markup,
@@ -109,6 +137,7 @@ class ConfigTokensForm extends ConfigFormBase {
          'colspan' => 2,
        ),
      );
    }

    return parent::buildForm($form, $form_state);
  }