Skip to content
Snippets Groups Projects
Commit 85510f9a authored by Fabiano Sant'Ana's avatar Fabiano Sant'Ana
Browse files

Merge commit 'e65b6f82' into 8.x-1.x

parents 8e9d85eb e65b6f82
Branches
Tags
No related merge requests found
...@@ -4,14 +4,3 @@ ...@@ -4,14 +4,3 @@
* @file * @file
* Functionality and helper functions for CAPTCHA administration. * Functionality and helper functions for CAPTCHA administration.
*/ */
/**
* Helper function for generating an example challenge.
*/
function _captcha_generate_example_challenge($module, $type) {
return [
'#type' => 'captcha',
'#captcha_type' => $module . '/' . $type,
'#captcha_admin_mode' => TRUE,
];
}
...@@ -57,7 +57,7 @@ class CaptchaExamplesForm extends FormBase { ...@@ -57,7 +57,7 @@ class CaptchaExamplesForm extends FormBase {
if ($module && $challenge) { if ($module && $challenge) {
// Generate 10 example challenges. // Generate 10 example challenges.
for ($i = 0; $i < 10; $i++) { for ($i = 0; $i < 10; $i++) {
$form["challenge_{$i}"] = _captcha_generate_example_challenge($module, $challenge); $form["challenge_{$i}"] = $this->buildChallenge($module, $challenge);
} }
} }
else { else {
...@@ -78,7 +78,7 @@ class CaptchaExamplesForm extends FormBase { ...@@ -78,7 +78,7 @@ class CaptchaExamplesForm extends FormBase {
'%challenge' => $challenge, '%challenge' => $challenge,
'%module' => $module, '%module' => $module,
]), ]),
'challenge' => _captcha_generate_example_challenge($module, $challenge), 'challenge' => $this->buildChallenge($module, $challenge),
'more_examples' => [ 'more_examples' => [
'#markup' => Link::fromTextAndUrl($this->t('10 more examples of this challenge.'), Url::fromRoute('captcha_examples', [ '#markup' => Link::fromTextAndUrl($this->t('10 more examples of this challenge.'), Url::fromRoute('captcha_examples', [
'module' => $module, 'module' => $module,
...@@ -97,8 +97,17 @@ class CaptchaExamplesForm extends FormBase { ...@@ -97,8 +97,17 @@ class CaptchaExamplesForm extends FormBase {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {}
/**
* Returns a renderable array for a given CAPTCHA challenge.
*/
protected function buildChallenge($module, $challenge) {
return [
'#type' => 'captcha',
'#captcha_type' => $module . '/' . $type,
'#captcha_admin_mode' => TRUE,
];
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment