class W3cValidatorSettingsForm in W3C Validator 8
Configuration settings page for W3C Validator page.
@internal
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, LinkGeneratorTrait, RedirectDestinationTrait, UrlGeneratorTrait, StringTranslationTrait
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
- class \Drupal\w3c_validator\Form\W3cValidatorSettingsForm
- class \Drupal\Core\Form\ConfigFormBase uses ConfigFormBaseTrait
Expanded class hierarchy of W3cValidatorSettingsForm
1 string reference to 'W3cValidatorSettingsForm'
File
- src/
Form/ W3cValidatorSettingsForm.php, line 19
Namespace
Drupal\w3c_validator\FormView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigFormBaseTrait:: |
protected | function | Retrieves a configuration object. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 1 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 1 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function |
Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait:: |
|
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
FormBase:: |
public | function |
Form validation handler. Overrides FormInterface:: |
62 |
LinkGeneratorTrait:: |
protected | property | The link generator. | 1 |
LinkGeneratorTrait:: |
protected | function | Returns the link generator. | |
LinkGeneratorTrait:: |
protected | function | Renders a link to a route given a route name and its parameters. | |
LinkGeneratorTrait:: |
public | function | Sets the link generator service. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. | |
W3cValidatorSettingsForm:: |
protected | property | The W3C validation processor. | |
W3cValidatorSettingsForm:: |
public | function |
Form constructor. Overrides ConfigFormBase:: |
|
W3cValidatorSettingsForm:: |
public static | function |
Instantiates a new instance of this class. Overrides ConfigFormBase:: |
|
W3cValidatorSettingsForm:: |
protected | function |
Gets the configuration names that will be editable. Overrides ConfigFormBaseTrait:: |
|
W3cValidatorSettingsForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
W3cValidatorSettingsForm:: |
public | function |
Form submission handler. Overrides ConfigFormBase:: |
|
W3cValidatorSettingsForm:: |
public | function |
Constructs a \Drupal\system\ConfigFormBase object. Overrides ConfigFormBase:: |