split config for turnstile + turnstile helper updates
CI / testsuite (mysql, 8.2, ) (push) Successful in 3m22s
CI / testsuite (mysql, 8.4, ) (push) Successful in 4m35s
CI / testsuite (pgsql, 8.2, ) (push) Successful in 3m9s
CI / testsuite (pgsql, 8.4, ) (push) Successful in 4m13s
CI / testsuite (sqlite, 8.2, ) (push) Successful in 3m5s
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Successful in 3m5s
CI / testsuite (sqlite, 8.4, ) (push) Successful in 4m14s
CI / Coding Standard & Static Analysis (push) Successful in 2m21s
CI / testsuite (mysql, 8.2, ) (push) Successful in 3m22s
CI / testsuite (mysql, 8.4, ) (push) Successful in 4m35s
CI / testsuite (pgsql, 8.2, ) (push) Successful in 3m9s
CI / testsuite (pgsql, 8.4, ) (push) Successful in 4m13s
CI / testsuite (sqlite, 8.2, ) (push) Successful in 3m5s
CI / testsuite (sqlite, 8.2, prefer-lowest) (push) Successful in 3m5s
CI / testsuite (sqlite, 8.4, ) (push) Successful in 4m14s
CI / Coding Standard & Static Analysis (push) Successful in 2m21s
This commit is contained in:
@@ -19,7 +19,9 @@ class TurnstileHelper extends Helper {
|
||||
*
|
||||
* @var array<string, mixed>
|
||||
*/
|
||||
protected array $_defaultConfig = [];
|
||||
protected array $_defaultConfig = [
|
||||
'eventListeners' => true,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array|string[]
|
||||
@@ -31,7 +33,7 @@ class TurnstileHelper extends Helper {
|
||||
* @param array<string, mixed> $config
|
||||
*/
|
||||
public function __construct(View $view, array $config = []) {
|
||||
$config += (array)Configure::read('ContactUs.turnstile');
|
||||
$config += (array)Configure::read('Turnstile');
|
||||
|
||||
parent::__construct($view, $config);
|
||||
}
|
||||
@@ -46,6 +48,31 @@ class TurnstileHelper extends Helper {
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render(array $options = []) {
|
||||
$options += [
|
||||
'class' => 'cf-turnstile',
|
||||
'data-sitekey' => $this->getConfigOrFail('siteKey'),
|
||||
'data-theme' => 'auto',
|
||||
'data-size' => 'flexible',
|
||||
'eventListeners' => $this->getConfig('eventListeners'),
|
||||
];
|
||||
if ($options['eventListeners']) {
|
||||
$options += [
|
||||
'data-callback' => 'onTurnstileSuccess',
|
||||
'data-error-callback' => 'onTurnstileError',
|
||||
'data-expired-callback' => 'onTurnstileExpired',
|
||||
];
|
||||
}
|
||||
unset($options['eventListeners']);
|
||||
|
||||
return $this->Html->div($options['class'], '', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $options
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function script(array $options = []) {
|
||||
@@ -80,7 +107,7 @@ class TurnstileHelper extends Helper {
|
||||
$final .= $this->onTurnstileExpired($options);
|
||||
$final .= '</script>';
|
||||
|
||||
return $final;
|
||||
return $this->Html->scriptBlock($final);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user