Commit f5d4338c authored by harsha012's avatar harsha012 Committed by naveenvalecha

Issue #2837488 by harsha012, naveenvalecha: t() calls should be avoided in classes

parent 8cc41927
......@@ -5,8 +5,6 @@
* Install, update and uninstall functions for the CAPTCHA module.
*/
use Drupal\Core\Url;
/**
* Implements hook_schema().
*/
......
......@@ -101,20 +101,20 @@ class CaptchaSettingsForm extends ConfigFormBase {
// Based on Drupal core's "Clear all caches" (performance settings page).
$form['form_protection']['placement_caching'] = [
'#type' => 'item',
'#title' => t('CAPTCHA placement caching'),
'#description' => t('For efficiency, the positions of the CAPTCHA elements in each of the configured forms are cached. Most of the time, the structure of a form does not change and it would be a waste to recalculate the positions every time. Occasionally however, the form structure can change (e.g. during site building) and clearing the CAPTCHA placement cache can be required to fix the CAPTCHA placement.'),
'#title' => $this->t('CAPTCHA placement caching'),
'#description' => $this->t('For efficiency, the positions of the CAPTCHA elements in each of the configured forms are cached. Most of the time, the structure of a form does not change and it would be a waste to recalculate the positions every time. Occasionally however, the form structure can change (e.g. during site building) and clearing the CAPTCHA placement cache can be required to fix the CAPTCHA placement.'),
];
$form['form_protection']['placement_caching']['placement_cache_clear'] = [
'#type' => 'submit',
'#value' => t('Clear the CAPTCHA placement cache'),
'#value' => $this->t('Clear the CAPTCHA placement cache'),
'#submit' => ['::clearCaptchaPlacementCacheSubmit'],
];
// Configuration option for adding a CAPTCHA description.
$form['add_captcha_description'] = [
'#type' => 'checkbox',
'#title' => t('Add a description to the CAPTCHA'),
'#description' => t('Add a configurable description to explain the purpose of the CAPTCHA to the visitor.'),
'#title' => $this->t('Add a description to the CAPTCHA'),
'#description' => $this->t('Add a configurable description to explain the purpose of the CAPTCHA to the visitor.'),
'#default_value' => $config->get('add_captcha_description'),
];
$form['description'] = [
......@@ -136,8 +136,8 @@ class CaptchaSettingsForm extends ConfigFormBase {
// Option for case sensitive/insensitive validation of the responses.
$form['default_validation'] = [
'#type' => 'radios',
'#title' => t('Default CAPTCHA validation'),
'#description' => t('Define how the response should be processed by default. Note that the modules that provide the actual challenges can override or ignore this.'),
'#title' => $this->t('Default CAPTCHA validation'),
'#description' => $this->t('Define how the response should be processed by default. Note that the modules that provide the actual challenges can override or ignore this.'),
'#options' => [
CAPTCHA_DEFAULT_VALIDATION_CASE_SENSITIVE => $this->t('Case sensitive validation: the response has to exactly match the solution.'),
CAPTCHA_DEFAULT_VALIDATION_CASE_INSENSITIVE => $this->t('Case insensitive validation: lowercase/uppercase errors are ignored.'),
......@@ -149,7 +149,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
// TODO for D7: Rethink/simplify the explanation and UI strings.
$form['persistence'] = [
'#type' => 'radios',
'#title' => t('Persistence'),
'#title' => $this->t('Persistence'),
'#default_value' => $config->get('persistence'),
'#options' => [
CAPTCHA_PERSISTENCE_SHOW_ALWAYS => $this->t('Always add a challenge.'),
......@@ -157,7 +157,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL_PER_FORM_TYPE => $this->t('Omit challenges on a form type once the user successfully responds to a challenge on a form of that type.'),
CAPTCHA_PERSISTENCE_SKIP_ONCE_SUCCESSFUL => $this->t('Omit challenges on all forms once the user successfully responds to any challenge on the site.'),
],
'#description' => t('Define if challenges should be omitted during the rest of a session once the user successfully responds to a challenge.'),
'#description' => $this->t('Define if challenges should be omitted during the rest of a session once the user successfully responds to a challenge.'),
];
// Enable wrong response counter.
......@@ -189,7 +189,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
$form['actions'] = ['#type' => 'actions'];
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => t('Save configuration'),
'#value' => $this->t('Save configuration'),
];
return parent::buildForm($form, $form_state);
......@@ -214,7 +214,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
$config->set('enable_stats', $form_state->getValue('enable_stats'));
$config->set('log_wrong_responses', $form_state->getValue('log_wrong_responses'));
$config->save();
drupal_set_message(t('The CAPTCHA settings have been saved.'), 'status');
drupal_set_message($this->t('The CAPTCHA settings have been saved.'), 'status');
parent::submitForm($form, $form_state);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment