forked from maikschneider/bw_captcha
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathext_localconf.php
59 lines (51 loc) · 2.25 KB
/
ext_localconf.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
use Blueways\BwCaptcha\Controller\CaptchaController;
use Blueways\BwCaptcha\Controller\CaptchaV12Controller;
use Blueways\BwCaptcha\Hooks\FormElementCaptchaHook;
use TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider;
use TYPO3\CMS\Core\Imaging\IconRegistry;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\VersionNumberUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;
defined('TYPO3') or die();
call_user_func(function () {
ExtensionManagementUtility::addTypoScriptSetup(trim('
module.tx_form {
settings {
yamlConfigurations {
1623227656 = EXT:bw_captcha/Configuration/Yaml/FormConfiguration.yaml
}
}
}
'));
$iconRegistry = GeneralUtility::makeInstance(IconRegistry::class);
$iconRegistry->registerIcon(
't3-form-captcha-element',
SvgIconProvider::class,
['source' => 'EXT:bw_captcha/Resources/Public/Images/form-captcha-icon.svg']
);
// get typo3 version
$verionNumberUtility = GeneralUtility::makeInstance(VersionNumberUtility::class);
$version = $verionNumberUtility->convertVersionStringToArray($verionNumberUtility->getNumericTypo3Version());
$captchaControllerName = $version['version_main'] < 12 ? CaptchaController::class : CaptchaV12Controller::class;
$captchaControllerName = $version['version_main'] < 10 ? 'Captcha' : $captchaControllerName;
$extensionName = $version['version_main'] < 11 ? 'Blueways.BwCaptcha' : 'BwCaptcha';
// register cache table
if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['bwcaptcha'])) {
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['bwcaptcha'] = [];
}
// register hook for captcha generation
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/form']['beforeRendering'][1630333427] = FormElementCaptchaHook::class;
// register plugin for captcha refresh endpoint
ExtensionUtility::configurePlugin(
$extensionName,
'Pi1',
[
$captchaControllerName => 'refresh',
],
[
$captchaControllerName => 'refresh',
]
);
});