Commit d3c9b8ed authored by JeroenT's avatar JeroenT Committed by wundo

Issue #3042586 by yogen.prasad, ChaseOnTheWeb, JeroenT, thalles, arpitr:...

Issue #3042586 by yogen.prasad, ChaseOnTheWeb, JeroenT, thalles, arpitr: Drupal 9 Deprecated Code Report
parent e9353227
......@@ -10,7 +10,6 @@
*/
use Drupal\captcha\Entity\CaptchaPoint;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Link;
......@@ -253,12 +252,10 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
$captcha_element['challenge'] = [
'#type' => 'item',
'#title' => t('Enabled challenge'),
'#markup' => t('<a href="@change">change</a>', [
'@change' => $captcha_point->url('edit-form', [
'query' => Drupal::destination()
->getAsArray(),
]),
]),
'#markup' => $captcha_point->toLink(t('change'), 'edit-form', [
'query' => \Drupal::destination()
->getAsArray(),
])->toString(),
];
}
else {
......@@ -267,7 +264,7 @@ function captcha_form_alter(array &$form, FormStateInterface $form_state, $form_
'#markup' => Link::fromTextAndUrl(
t('Place a CAPTCHA here for untrusted users.'),
Url::fromRoute('captcha_point.add', [], [
'query' => Drupal::destination()
'query' => \Drupal::destination()
->getAsArray() + ['form_id' => $form_id],
])
)->toString(),
......@@ -317,7 +314,7 @@ function captcha_validate_strict_equality($solution, $response) {
* TRUE when case insensitive equal, FALSE otherwise.
*/
function captcha_validate_case_insensitive_equality($solution, $response) {
return Unicode::strtolower($solution) === Unicode::strtolower($response);
return mb_strtolower($solution) === mb_strtolower($response);
}
/**
......@@ -347,7 +344,7 @@ function captcha_validate_ignore_spaces($solution, $response) {
* TRUE when equal (ignoring spaces), FALSE otherwise.
*/
function captcha_validate_case_insensitive_ignore_spaces($solution, $response) {
return preg_replace('/\s/', '', Unicode::strtolower($solution)) === preg_replace('/\s/', '', Unicode::strtolower($response));
return preg_replace('/\s/', '', mb_strtolower($solution)) === preg_replace('/\s/', '', mb_strtolower($response));
}
/**
......
......@@ -9,6 +9,7 @@ namespace Drupal\image_captcha\Controller;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Database\Database;
use Drupal\Core\Url;
/**
* Description of CaptchaImageRefresh.
......@@ -43,7 +44,7 @@ class CaptchaImageRefresh extends ControllerBase {
->condition('csid', $captcha_sid, '=')
->execute();
$result['data'] = [
'url' => \Drupal::url('image_captcha.generator', ['session_id' => $captcha_sid, 'timestamp' => \Drupal::time()->getRequestTime()]),
'url' => Url::fromRoute('image_captcha.generator', ['session_id' => $captcha_sid, 'timestamp' => \Drupal::time()->getRequestTime()])->toString(),
'token' => $captcha_token,
'sid' => $captcha_sid,
];
......
......@@ -72,10 +72,10 @@ class ImageCaptchaSettingsForm extends ConfigFormBase {
// First some error checking.
$setup_status = _image_captcha_check_setup(FALSE);
if ($setup_status & IMAGE_CAPTCHA_ERROR_NO_GDLIB) {
drupal_set_message($this->t(
$this->messenger()->addError($this->t(
'The Image CAPTCHA module can not generate images because your PHP setup does not support it (no <a href="!gdlib" target="_blank">GD library</a> with JPEG support).',
['!gdlib' => 'http://php.net/manual/en/book.image.php']
), 'error');
));
// It is no use to continue building the rest of the settings form.
return $form;
}
......
......@@ -41,7 +41,7 @@ class LongIdForm extends FormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
// Display result.
foreach ($form_state->getValues() as $key => $value) {
drupal_set_message($key . ': ' . $value);
$this->messenger()->addMessage($key . ': ' . $value);
}
}
......
......@@ -37,7 +37,7 @@ class CaptchaPointDeleteForm extends EntityConfirmFormBase {
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->delete();
drupal_set_message($this->t('Captcha point %label has been deleted.', ['%label' => $this->entity->label()]));
$this->messenger()->addMessage($this->t('Captcha point %label has been deleted.', ['%label' => $this->entity->label()]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
......
......@@ -45,7 +45,7 @@ class CaptchaPointDisableForm extends EntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->disable();
$this->entity->save();
drupal_set_message($this->t('Captcha point %label has been disabled.', ['%label' => $this->entity->label()]));
$this->messenger()->addMessage($this->t('Captcha point %label has been disabled.', ['%label' => $this->entity->label()]));
$form_state->setRedirect('captcha_point.list');
}
......
......@@ -45,7 +45,7 @@ class CaptchaPointEnableForm extends EntityConfirmFormBase {
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->entity->enable();
$this->entity->save();
drupal_set_message($this->t('Captcha point %label has been enabled.', ['%label' => $this->entity->label()]));
$this->messenger()->addMessage($this->t('Captcha point %label has been enabled.', ['%label' => $this->entity->label()]));
$form_state->setRedirect('captcha_point.list');
}
......
......@@ -101,12 +101,12 @@ class CaptchaPointForm extends EntityForm {
$status = $captcha_point->save();
if ($status == SAVED_NEW) {
drupal_set_message($this->t('Captcha Point for %form_id form was created.', [
$this->messenger()->addMessage($this->t('Captcha Point for %form_id form was created.', [
'%form_id' => $captcha_point->getFormId(),
]));
}
else {
drupal_set_message($this->t('Captcha Point for %form_id form was updated.', [
$this->messenger()->addMessage($this->t('Captcha Point for %form_id form was updated.', [
'%form_id' => $captcha_point->getFormId(),
]));
}
......
......@@ -234,7 +234,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($this->t('The CAPTCHA settings have been saved.'), 'status');
$this->messenger()->addStatus($this->t('The CAPTCHA settings have been saved.'));
parent::submitForm($form, $form_state);
}
......@@ -249,7 +249,7 @@ class CaptchaSettingsForm extends ConfigFormBase {
*/
public function clearCaptchaPlacementCacheSubmit(array $form, FormStateInterface $form_state) {
$this->cacheBackend->delete('captcha_placement_map_cache');
drupal_set_message($this->t('Cleared the CAPTCHA placement cache.'));
$this->messenger()->addMessage($this->t('Cleared the CAPTCHA placement cache.'));
}
}
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