You are here

class W3cValidatorSettingsForm in W3C Validator 8

Configuration settings page for W3C Validator page.

@internal

Hierarchy

Expanded class hierarchy of W3cValidatorSettingsForm

1 string reference to 'W3cValidatorSettingsForm'
w3c_validator.routing.yml in ./w3c_validator.routing.yml
w3c_validator.routing.yml

File

src/Form/W3cValidatorSettingsForm.php, line 19

Namespace

Drupal\w3c_validator\Form
View source
class W3cValidatorSettingsForm extends ConfigFormBase {

  /**
   * The W3C validation processor.
   *
   * @var \Drupal\w3c_validator\W3CProcessor
   */
  protected $w3cProcessor;

  /**
   * Constructs a \Drupal\system\ConfigFormBase object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The factory for configuration objects.
   * @param \Drupal\w3c_validator\W3CProcessor $w3c_processor
   *   The w3c validation processor.
   */
  public function __construct(ConfigFactoryInterface $config_factory, W3CProcessor $w3c_processor) {
    parent::__construct($config_factory);
    $this->w3cProcessor = $w3c_processor;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('config.factory'), $container
      ->get('w3c.processor'));
  }

  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'w3c_validator_settings_form';
  }

  /**
   * {@inheritdoc}
   */
  protected function getEditableConfigNames() {
    return [
      'w3c_validator.settings',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $form = parent::buildForm($form, $form_state);
    $form['w3c_validator'] = [
      '#markup' => $this
        ->t('This module uses the official W3c Validator scripts. We strongly recommand to install the official w3c validator on your own server and provide the url here? You can also use the official online w3c validator service.') . '<br />' . $this
        ->t('For instructions on how to install an instance of the w3c validator scripts you have instructions at <a href="http://validator.w3.org/docs/install.html">http://validator.w3.org/docs/install.html</a>.') . '<br />' . $this
        ->t('Debian based distributions comes with a package called <em>w3c_markup_validator</em> which provides a ready to use install of the validator.') . '<br />' . $this
        ->t('Using the official W3C validator endpoint url for high volume of validations could be considered abuse of service.'),
    ];
    $form['validator_url'] = [
      '#type' => 'url',
      '#title' => t('W3C Validator API endpoint URI'),
      '#description' => t('URL of the validator script where API call will be targeted.') . '<br/>' . $this
        ->t('You can use the official service at @w3cvalidator althought its not recommended.', [
        '@w3cvalidator' => Link::fromTextAndUrl('http://validator.w3.org/check', Url::fromUri('http://validator.w3.org/check'))
          ->toString(),
      ]) . '<br/>' . $this
        ->t('Leave empty to use the default installed validator path: @validator.', [
        '@validator' => Link::fromTextAndUrl(Validator::DEFAULT_VALIDATOR_URL, Url::fromUri(Validator::DEFAULT_VALIDATOR_URL))
          ->toString(),
      ]),
      '#default_value' => $this->w3cProcessor
        ->getValidatorUrl(),
    ];
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    parent::submitForm($form, $form_state);
    $this
      ->config('w3c_validator.settings')
      ->set('validator_url', $form_state
      ->getValue('validator_url'))
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigFormBaseTrait::config protected function Retrieves a configuration object.
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
FormBase::validateForm public function Form validation handler. Overrides FormInterface::validateForm 62
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.
W3cValidatorSettingsForm::$w3cProcessor protected property The W3C validation processor.
W3cValidatorSettingsForm::buildForm public function Form constructor. Overrides ConfigFormBase::buildForm
W3cValidatorSettingsForm::create public static function Instantiates a new instance of this class. Overrides ConfigFormBase::create
W3cValidatorSettingsForm::getEditableConfigNames protected function Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait::getEditableConfigNames
W3cValidatorSettingsForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId
W3cValidatorSettingsForm::submitForm public function Form submission handler. Overrides ConfigFormBase::submitForm
W3cValidatorSettingsForm::__construct public function Constructs a \Drupal\system\ConfigFormBase object. Overrides ConfigFormBase::__construct