Commit 85510f9a authored by wundo's avatar wundo

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

parents 8e9d85eb e65b6f82
......@@ -4,14 +4,3 @@
* @file
* 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 {
if ($module && $challenge) {
// Generate 10 example challenges.
for ($i = 0; $i < 10; $i++) {
$form["challenge_{$i}"] = _captcha_generate_example_challenge($module, $challenge);
$form["challenge_{$i}"] = $this->buildChallenge($module, $challenge);
}
}
else {
......@@ -78,7 +78,7 @@ class CaptchaExamplesForm extends FormBase {
'%challenge' => $challenge,
'%module' => $module,
]),
'challenge' => _captcha_generate_example_challenge($module, $challenge),
'challenge' => $this->buildChallenge($module, $challenge),
'more_examples' => [
'#markup' => Link::fromTextAndUrl($this->t('10 more examples of this challenge.'), Url::fromRoute('captcha_examples', [
'module' => $module,
......@@ -97,8 +97,17 @@ class CaptchaExamplesForm extends FormBase {
/**
* {@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,
];
}
}
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