diff --git a/ReCaptchaAdminUi/Model/CaptchaTypeResolver.php b/ReCaptchaAdminUi/Model/CaptchaTypeResolver.php index 0b89bb25..d845d9dd 100644 --- a/ReCaptchaAdminUi/Model/CaptchaTypeResolver.php +++ b/ReCaptchaAdminUi/Model/CaptchaTypeResolver.php @@ -36,9 +36,6 @@ public function __construct( */ public function getCaptchaTypeFor(string $key): ?string { - $type = $this->scopeConfig->getValue( - self::XML_PATH_TYPE_FOR . $key - ); - return $type; + return $this->scopeConfig->getValue(self::XML_PATH_TYPE_FOR . $key); } } diff --git a/ReCaptchaAdminUi/Model/ErrorMessageConfig.php b/ReCaptchaAdminUi/Model/ErrorMessageConfig.php index c1ee222b..2ac14f4b 100644 --- a/ReCaptchaAdminUi/Model/ErrorMessageConfig.php +++ b/ReCaptchaAdminUi/Model/ErrorMessageConfig.php @@ -38,10 +38,7 @@ public function __construct( */ public function getTechnicalFailureMessage(): string { - return $this->scopeConfig->getValue( - self::XML_PATH_TECHNICAL, - ScopeInterface::SCOPE_STORE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_TECHNICAL, ScopeInterface::SCOPE_STORE); } /** @@ -49,9 +46,6 @@ public function getTechnicalFailureMessage(): string */ public function getValidationFailureMessage(): string { - return $this->scopeConfig->getValue( - self::XML_PATH_VALIDATION, - ScopeInterface::SCOPE_STORE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION, ScopeInterface::SCOPE_STORE); } } diff --git a/ReCaptchaAdminUi/Model/OptionSource.php b/ReCaptchaAdminUi/Model/OptionSource.php index 12cc6a92..d5d4ffa4 100644 --- a/ReCaptchaAdminUi/Model/OptionSource.php +++ b/ReCaptchaAdminUi/Model/OptionSource.php @@ -8,6 +8,7 @@ namespace Magento\ReCaptchaAdminUi\Model; use Magento\Framework\Data\OptionSourceInterface; +use function array_values; /** * Generic class for reCAPTCHA Stores/System Configuration options @@ -29,14 +30,14 @@ class OptionSource implements OptionSourceInterface */ public function __construct(array $options = []) { - $this->options = $options; + $this->options = array_values($options); } /** - * @inheritDoc + * @inheritdoc */ public function toOptionArray(): array { - return array_values($this->options); + return $this->options; } } diff --git a/ReCaptchaAdminUi/etc/adminhtml/system.xml b/ReCaptchaAdminUi/etc/adminhtml/system.xml index 01e6bb50..2d45b35d 100644 --- a/ReCaptchaAdminUi/etc/adminhtml/system.xml +++ b/ReCaptchaAdminUi/etc/adminhtml/system.xml @@ -5,38 +5,45 @@ * See COPYING.txt for license details. */ --> - + -
+
separator-top - + security Magento_ReCaptchaUi::config + + + + + Magento\ReCaptchaAdminUi\Model\OptionSource\ApiUrl + + +
- + separator-top + + security + Magento_ReCaptchaUi::config + - + Magento\ReCaptchaAdminUi\Block\Adminhtml\System\Config\Form\Field\Notice - + - - @@ -44,18 +51,14 @@
-
+
separator-top security Magento_ReCaptchaUi::config - - + - + Magento\ReCaptchaAdminUi\Block\Adminhtml\System\Config\Form\Field\Notice diff --git a/ReCaptchaAdminUi/etc/di.xml b/ReCaptchaAdminUi/etc/di.xml index 98bba132..e3cf6d11 100644 --- a/ReCaptchaAdminUi/etc/di.xml +++ b/ReCaptchaAdminUi/etc/di.xml @@ -5,10 +5,8 @@ * See COPYING.txt for license details. */ --> - - + + @@ -18,4 +16,18 @@ + + + + + www.google.com + https://www.google.com/recaptcha/api.js + + + www.recaptcha.net + https://www.recaptcha.net/recaptcha/api.js + + + + diff --git a/ReCaptchaAdminUi/etc/module.xml b/ReCaptchaAdminUi/etc/module.xml index 2f916eba..8815651d 100644 --- a/ReCaptchaAdminUi/etc/module.xml +++ b/ReCaptchaAdminUi/etc/module.xml @@ -5,7 +5,12 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + + diff --git a/ReCaptchaAdminUi/registration.php b/ReCaptchaAdminUi/registration.php index a6e545b4..5d7db1fb 100644 --- a/ReCaptchaAdminUi/registration.php +++ b/ReCaptchaAdminUi/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaAdminUi', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaAdminUi', __DIR__); diff --git a/ReCaptchaCheckout/Block/LayoutProcessor/Checkout/Onepage.php b/ReCaptchaCheckout/Block/LayoutProcessor/Checkout/Onepage.php index 17883e33..31595635 100644 --- a/ReCaptchaCheckout/Block/LayoutProcessor/Checkout/Onepage.php +++ b/ReCaptchaCheckout/Block/LayoutProcessor/Checkout/Onepage.php @@ -46,7 +46,7 @@ public function __construct( * @return array * @throws InputException */ - public function process($jsLayout) + public function process($jsLayout): array { $key = 'customer_login'; if ($this->isCaptchaEnabled->isCaptchaEnabledFor($key)) { @@ -76,6 +76,7 @@ public function process($jsLayout) unset($jsLayout['components']['checkout']['children']['authentication']['children']['recaptcha']); } } + return $jsLayout; } } diff --git a/ReCaptchaCheckout/etc/module.xml b/ReCaptchaCheckout/etc/module.xml index b260cb48..cf61136d 100644 --- a/ReCaptchaCheckout/etc/module.xml +++ b/ReCaptchaCheckout/etc/module.xml @@ -5,7 +5,11 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + diff --git a/ReCaptchaCheckout/registration.php b/ReCaptchaCheckout/registration.php index 10e710d0..6f0ea96b 100644 --- a/ReCaptchaCheckout/registration.php +++ b/ReCaptchaCheckout/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaCheckout', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaCheckout', __DIR__); diff --git a/ReCaptchaCheckout/view/frontend/layout/checkout_index_index.xml b/ReCaptchaCheckout/view/frontend/layout/checkout_index_index.xml index cb469553..44609196 100644 --- a/ReCaptchaCheckout/view/frontend/layout/checkout_index_index.xml +++ b/ReCaptchaCheckout/view/frontend/layout/checkout_index_index.xml @@ -5,9 +5,7 @@ * See COPYING.txt for license details. */ --> - - + @@ -55,7 +53,6 @@ - diff --git a/ReCaptchaContact/etc/module.xml b/ReCaptchaContact/etc/module.xml index 10f3f1ed..6e915d75 100644 --- a/ReCaptchaContact/etc/module.xml +++ b/ReCaptchaContact/etc/module.xml @@ -5,7 +5,10 @@ * See COPYING.txt for license details. */ --> - - + + + + + + diff --git a/ReCaptchaContact/registration.php b/ReCaptchaContact/registration.php index aac21c51..bd159ab7 100644 --- a/ReCaptchaContact/registration.php +++ b/ReCaptchaContact/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaContact', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaContact', __DIR__); diff --git a/ReCaptchaContact/view/frontend/layout/contact_index_index.xml b/ReCaptchaContact/view/frontend/layout/contact_index_index.xml index 7068b36d..0deb9b5b 100644 --- a/ReCaptchaContact/view/frontend/layout/contact_index_index.xml +++ b/ReCaptchaContact/view/frontend/layout/contact_index_index.xml @@ -5,8 +5,7 @@ * See COPYING.txt for license details. */ --> - + - - + + + + + + + + diff --git a/ReCaptchaFrontendUi/Model/CaptchaTypeResolver.php b/ReCaptchaFrontendUi/Model/CaptchaTypeResolver.php index 56ce5019..063a509d 100644 --- a/ReCaptchaFrontendUi/Model/CaptchaTypeResolver.php +++ b/ReCaptchaFrontendUi/Model/CaptchaTypeResolver.php @@ -37,10 +37,6 @@ public function __construct( */ public function getCaptchaTypeFor(string $key): ?string { - $type = $this->scopeConfig->getValue( - self::XML_PATH_TYPE_FOR . $key, - ScopeInterface::SCOPE_WEBSITE - ); - return $type; + return $this->scopeConfig->getValue(self::XML_PATH_TYPE_FOR . $key, ScopeInterface::SCOPE_WEBSITE); } } diff --git a/ReCaptchaFrontendUi/Model/ErrorMessageConfig.php b/ReCaptchaFrontendUi/Model/ErrorMessageConfig.php index 47234e8d..2cc2b477 100644 --- a/ReCaptchaFrontendUi/Model/ErrorMessageConfig.php +++ b/ReCaptchaFrontendUi/Model/ErrorMessageConfig.php @@ -38,10 +38,7 @@ public function __construct( */ public function getTechnicalFailureMessage(): string { - return $this->scopeConfig->getValue( - self::XML_PATH_TECHNICAL, - ScopeInterface::SCOPE_STORE - ); + return $this->scopeConfig->getValue(self::XML_PATH_TECHNICAL, ScopeInterface::SCOPE_STORE); } /** @@ -49,9 +46,6 @@ public function getTechnicalFailureMessage(): string */ public function getValidationFailureMessage(): string { - return $this->scopeConfig->getValue( - self::XML_PATH_VALIDATION, - ScopeInterface::SCOPE_STORE - ); + return $this->scopeConfig->getValue(self::XML_PATH_VALIDATION, ScopeInterface::SCOPE_STORE); } } diff --git a/ReCaptchaFrontendUi/Plugin/ExcludeFromMinification.php b/ReCaptchaFrontendUi/Plugin/ExcludeFromMinification.php deleted file mode 100644 index 0f416d05..00000000 --- a/ReCaptchaFrontendUi/Plugin/ExcludeFromMinification.php +++ /dev/null @@ -1,34 +0,0 @@ - - - - diff --git a/ReCaptchaFrontendUi/etc/module.xml b/ReCaptchaFrontendUi/etc/module.xml index b3b392d9..4f7b2cf2 100644 --- a/ReCaptchaFrontendUi/etc/module.xml +++ b/ReCaptchaFrontendUi/etc/module.xml @@ -5,7 +5,11 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + diff --git a/ReCaptchaFrontendUi/registration.php b/ReCaptchaFrontendUi/registration.php index ba5e8ba4..de5cf026 100644 --- a/ReCaptchaFrontendUi/registration.php +++ b/ReCaptchaFrontendUi/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaFrontendUi', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaFrontendUi', __DIR__); diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index ddd627f2..555576aa 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -51,7 +51,7 @@ define( $(window).trigger('recaptchaapiready'); }.bind(this); - reCaptchaLoader.addReCaptchaScriptTag(); + reCaptchaLoader.addReCaptchaScriptTag(this.settings.api_url); }, /** diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptchaScriptLoader.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptchaScriptLoader.js index 94746c33..e7673b64 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptchaScriptLoader.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptchaScriptLoader.js @@ -12,7 +12,7 @@ define([], function () { /** * Add script tag. Script tag should be added once */ - addReCaptchaScriptTag: function () { + addReCaptchaScriptTag: function (apiUrl) { var element, scriptTag; if (!scriptTagAdded) { @@ -20,8 +20,7 @@ define([], function () { scriptTag = document.getElementsByTagName('script')[0]; element.async = true; - element.src = 'https://www.google.com/recaptcha/api.js' + - '?onload=globalOnRecaptchaOnLoadCallback&render=explicit'; + element.src = apiUrl + '?onload=globalOnRecaptchaOnLoadCallback&render=explicit'; scriptTag.parentNode.insertBefore(element, scriptTag); scriptTagAdded = true; diff --git a/ReCaptchaMigration/Setup/Patch/Data/MigrateConfigToRecaptchaModules.php b/ReCaptchaMigration/Setup/Patch/Data/MigrateConfigToRecaptchaModules.php index 1c131d6a..6f6e6319 100644 --- a/ReCaptchaMigration/Setup/Patch/Data/MigrateConfigToRecaptchaModules.php +++ b/ReCaptchaMigration/Setup/Patch/Data/MigrateConfigToRecaptchaModules.php @@ -60,7 +60,7 @@ public function __construct( /** * @inheritdoc */ - public function apply() + public function apply(): self { $scopes = ['frontend', 'backend']; foreach ($scopes as $scope) { @@ -69,6 +69,8 @@ public function apply() $this->copyEnabledRecaptcha($scope); $this->disableLegacyRecaptcha($scope); } + + return $this; } /** @@ -250,7 +252,7 @@ private function copyRecord(string $srcPath, string $dstPath): void /** * @inheritdoc */ - public static function getDependencies() + public static function getDependencies(): array { return []; } @@ -258,7 +260,7 @@ public static function getDependencies() /** * @inheritdoc */ - public static function getVersion() + public static function getVersion(): string { return '3.0.0'; } @@ -266,7 +268,7 @@ public static function getVersion() /** * @inheritdoc */ - public function getAliases() + public function getAliases(): array { return []; } diff --git a/ReCaptchaMigration/etc/module.xml b/ReCaptchaMigration/etc/module.xml index be65c266..f664e9cf 100644 --- a/ReCaptchaMigration/etc/module.xml +++ b/ReCaptchaMigration/etc/module.xml @@ -5,7 +5,10 @@ * See COPYING.txt for license details. */ --> - - + + + + + + diff --git a/ReCaptchaMigration/registration.php b/ReCaptchaMigration/registration.php index d47e5be1..823af8e0 100644 --- a/ReCaptchaMigration/registration.php +++ b/ReCaptchaMigration/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaMigration', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaMigration', __DIR__); diff --git a/ReCaptchaNewsletter/etc/module.xml b/ReCaptchaNewsletter/etc/module.xml index f684e0f8..477827f8 100644 --- a/ReCaptchaNewsletter/etc/module.xml +++ b/ReCaptchaNewsletter/etc/module.xml @@ -5,7 +5,10 @@ * See COPYING.txt for license details. */ --> - - + + + + + + diff --git a/ReCaptchaNewsletter/registration.php b/ReCaptchaNewsletter/registration.php index e5c20536..f24c1462 100644 --- a/ReCaptchaNewsletter/registration.php +++ b/ReCaptchaNewsletter/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaNewsletter', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaNewsletter', __DIR__); diff --git a/ReCaptchaPaypal/Block/LayoutProcessor/Checkout/Onepage.php b/ReCaptchaPaypal/Block/LayoutProcessor/Checkout/Onepage.php index bd8027af..f543bfaf 100644 --- a/ReCaptchaPaypal/Block/LayoutProcessor/Checkout/Onepage.php +++ b/ReCaptchaPaypal/Block/LayoutProcessor/Checkout/Onepage.php @@ -46,7 +46,7 @@ public function __construct( * @return array * @throws InputException */ - public function process($jsLayout) + public function process($jsLayout): array { $key = 'paypal_payflowpro'; if ($this->isCaptchaEnabled->isCaptchaEnabledFor($key)) { diff --git a/ReCaptchaPaypal/Model/CheckoutConfigProvider.php b/ReCaptchaPaypal/Model/CheckoutConfigProvider.php index ce2a338c..d8364937 100644 --- a/ReCaptchaPaypal/Model/CheckoutConfigProvider.php +++ b/ReCaptchaPaypal/Model/CheckoutConfigProvider.php @@ -32,7 +32,7 @@ public function __construct( /** * @inheritdoc */ - public function getConfig() + public function getConfig(): array { return [ 'recaptcha_paypal' => $this->isCaptchaEnabled->isCaptchaEnabledFor('paypal_payflowpro') diff --git a/ReCaptchaPaypal/etc/module.xml b/ReCaptchaPaypal/etc/module.xml index 2f140fdb..86d75fc7 100644 --- a/ReCaptchaPaypal/etc/module.xml +++ b/ReCaptchaPaypal/etc/module.xml @@ -5,7 +5,12 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + + diff --git a/ReCaptchaPaypal/registration.php b/ReCaptchaPaypal/registration.php index 2e3ebb0e..d29485b1 100644 --- a/ReCaptchaPaypal/registration.php +++ b/ReCaptchaPaypal/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaPaypal', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaPaypal', __DIR__); diff --git a/ReCaptchaReview/etc/module.xml b/ReCaptchaReview/etc/module.xml index 9691a735..1f73f046 100644 --- a/ReCaptchaReview/etc/module.xml +++ b/ReCaptchaReview/etc/module.xml @@ -5,7 +5,10 @@ * See COPYING.txt for license details. */ --> - - + + + + + + diff --git a/ReCaptchaReview/registration.php b/ReCaptchaReview/registration.php index 8b2cae1b..51aaf23f 100644 --- a/ReCaptchaReview/registration.php +++ b/ReCaptchaReview/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaReview', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaReview', __DIR__); diff --git a/ReCaptchaSendFriend/etc/module.xml b/ReCaptchaSendFriend/etc/module.xml index 9a3e3a08..a89eca2d 100644 --- a/ReCaptchaSendFriend/etc/module.xml +++ b/ReCaptchaSendFriend/etc/module.xml @@ -5,7 +5,10 @@ * See COPYING.txt for license details. */ --> - - + + + + + + diff --git a/ReCaptchaSendFriend/registration.php b/ReCaptchaSendFriend/registration.php index 9f72af49..383cda65 100644 --- a/ReCaptchaSendFriend/registration.php +++ b/ReCaptchaSendFriend/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaSendFriend', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaSendFriend', __DIR__); diff --git a/ReCaptchaStorePickup/etc/module.xml b/ReCaptchaStorePickup/etc/module.xml index 4c62fcfa..f4050a68 100644 --- a/ReCaptchaStorePickup/etc/module.xml +++ b/ReCaptchaStorePickup/etc/module.xml @@ -5,7 +5,11 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + diff --git a/ReCaptchaStorePickup/registration.php b/ReCaptchaStorePickup/registration.php index 8d2d190d..0eafcc6e 100644 --- a/ReCaptchaStorePickup/registration.php +++ b/ReCaptchaStorePickup/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaStorePickup', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaStorePickup', __DIR__); diff --git a/ReCaptchaUi/Block/ReCaptcha.php b/ReCaptchaUi/Block/ReCaptcha.php index cca673d3..05db0f12 100644 --- a/ReCaptchaUi/Block/ReCaptcha.php +++ b/ReCaptchaUi/Block/ReCaptcha.php @@ -56,7 +56,7 @@ public function __construct( /** * Get reCAPTCHA ID */ - public function getRecaptchaId() + public function getRecaptchaId(): string { return (string)$this->getData('recaptcha_id') ?: 'recaptcha-' . sha1($this->getNameInLayout()); } @@ -67,7 +67,7 @@ public function getRecaptchaId() * @return string * @throws InputException */ - public function getJsLayout() + public function getJsLayout(): string { $layout = $this->serializer->unserialize(parent::getJsLayout()); @@ -95,15 +95,10 @@ public function getJsLayout() */ public function getCaptchaUiConfig(): array { - $key = $this->getData('recaptcha_for'); - $uiConfig = $this->getData('captcha_ui_config'); + $key = (string) $this->getData('recaptcha_for'); + $uiConfig = (array) $this->getData('captcha_ui_config'); - if ($uiConfig) { - $uiConfig = array_replace_recursive($this->captchaUiConfigResolver->get($key), $uiConfig); - } else { - $uiConfig = $this->captchaUiConfigResolver->get($key); - } - return $uiConfig; + return array_replace_recursive($this->captchaUiConfigResolver->get($key), $uiConfig); } @@ -111,7 +106,7 @@ public function getCaptchaUiConfig(): array * @return string * @throws InputException */ - public function toHtml() + public function toHtml(): string { $key = $this->getData('recaptcha_for'); if (empty($key) || !$this->isCaptchaEnabled->isCaptchaEnabledFor($key)) { diff --git a/ReCaptchaUi/Model/CaptchaResponseResolver.php b/ReCaptchaUi/Model/CaptchaResponseResolver.php index 53c92d86..de3d6b64 100644 --- a/ReCaptchaUi/Model/CaptchaResponseResolver.php +++ b/ReCaptchaUi/Model/CaptchaResponseResolver.php @@ -21,9 +21,10 @@ class CaptchaResponseResolver implements CaptchaResponseResolverInterface public function resolve(RequestInterface $request): string { $reCaptchaParam = $request->getParam(self::PARAM_RECAPTCHA); - if (empty($reCaptchaParam)) { + if (!$reCaptchaParam) { throw new InputException(__('Can not resolve reCAPTCHA parameter.')); } + return $reCaptchaParam; } } diff --git a/ReCaptchaUi/Model/IsCaptchaEnabled.php b/ReCaptchaUi/Model/IsCaptchaEnabled.php index 8eaf8b12..26a70848 100644 --- a/ReCaptchaUi/Model/IsCaptchaEnabled.php +++ b/ReCaptchaUi/Model/IsCaptchaEnabled.php @@ -65,7 +65,6 @@ private function areKeysConfigured(string $key): bool $validationConfig = $this->validationConfigResolver->get($key); // TODO: - return $validationConfig->getPrivateKey() - && !empty($uiConfig['rendering']['sitekey']); + return $validationConfig->getPrivateKey() && !empty($uiConfig['rendering']['sitekey']); } } diff --git a/ReCaptchaUi/Model/UiConfigProvider.php b/ReCaptchaUi/Model/UiConfigProvider.php new file mode 100644 index 00000000..f5e8a2d8 --- /dev/null +++ b/ReCaptchaUi/Model/UiConfigProvider.php @@ -0,0 +1,38 @@ +scopeConfig = $scopeConfig; + } + + private function getApiUrl(): string + { + return (string)$this->scopeConfig->getValue(self::CONFIG_PATH_RECAPTCHA_API_URL, ScopeInterface::SCOPE_WEBSITE); + } + + public function get(): array + { + return [ + 'api_url' => $this->getApiUrl(), + ]; + } +} diff --git a/ReCaptchaUi/Model/UiConfigResolver.php b/ReCaptchaUi/Model/UiConfigResolver.php index 5ca000ad..cb631429 100644 --- a/ReCaptchaUi/Model/UiConfigResolver.php +++ b/ReCaptchaUi/Model/UiConfigResolver.php @@ -8,6 +8,10 @@ namespace Magento\ReCaptchaUi\Model; use Magento\Framework\Exception\InputException; +use function array_combine; +use function array_keys; +use function array_merge_recursive; +use function array_values; /** * Extension point for reCAPTCHA UI config @@ -17,6 +21,8 @@ */ class UiConfigResolver implements UiConfigResolverInterface { + private const DEFAULT_CAPTCHA_CONFIG = 'default'; + /** * @var CaptchaTypeResolverInterface */ @@ -30,22 +36,18 @@ class UiConfigResolver implements UiConfigResolverInterface /** * @param CaptchaTypeResolverInterface $captchaTypeResolver * @param UiConfigProviderInterface[] $uiConfigProviders - * @throws InputException */ public function __construct( CaptchaTypeResolverInterface $captchaTypeResolver, array $uiConfigProviders = [] ) { $this->captchaTypeResolver = $captchaTypeResolver; - - foreach ($uiConfigProviders as $uiConfigProvider) { - if (!$uiConfigProvider instanceof UiConfigProviderInterface) { - throw new InputException( - __('UI config provider must implement %1', [ UiConfigResolverInterface::class]) - ); - } - } - $this->uiConfigProviders = $uiConfigProviders; + $this->uiConfigProviders = array_combine( + array_keys($uiConfigProviders), + (static function (UiConfigProviderInterface ...$uiConfigProviders): array { + return $uiConfigProviders; + })(...array_values($uiConfigProviders)) + ); } /** @@ -60,6 +62,10 @@ public function get(string $key): array __('UI config provider for "%type" is not configured.', ['type' => $captchaType]) ); } - return $this->uiConfigProviders[$captchaType]->get(); + + return array_merge_recursive( + $this->uiConfigProviders[self::DEFAULT_CAPTCHA_CONFIG]->get(), + $this->uiConfigProviders[$captchaType]->get() + ); } } diff --git a/ReCaptchaUi/Model/ValidationConfigResolver.php b/ReCaptchaUi/Model/ValidationConfigResolver.php index 4ff3b428..b17285a6 100644 --- a/ReCaptchaUi/Model/ValidationConfigResolver.php +++ b/ReCaptchaUi/Model/ValidationConfigResolver.php @@ -9,6 +9,9 @@ use Magento\Framework\Exception\InputException; use Magento\ReCaptchaValidationApi\Api\Data\ValidationConfigInterface; +use function array_combine; +use function array_keys; +use function array_values; /** * Extension point for resolving reCAPTCHA Validation config @@ -33,22 +36,18 @@ class ValidationConfigResolver implements ValidationConfigResolverInterface /** * @param CaptchaTypeResolverInterface $captchaTypeResolver * @param ValidationConfigProviderInterface[] $validationConfigProviders - * @throws InputException */ public function __construct( CaptchaTypeResolverInterface $captchaTypeResolver, array $validationConfigProviders = [] ) { $this->captchaTypeResolver = $captchaTypeResolver; - - foreach ($validationConfigProviders as $validationConfigProvider) { - if (!$validationConfigProvider instanceof ValidationConfigProviderInterface) { - throw new InputException( - __('Validation config provider must implement %1.', [ConfigProviderInterface::class]) - ); - } - } - $this->validationConfigProviders = $validationConfigProviders; + $this->validationConfigProviders = array_combine( + array_keys($validationConfigProviders), + (static function (ValidationConfigProviderInterface ...$validationConfigProviders): array { + return $validationConfigProviders; + })(...array_values($validationConfigProviders)) + ); } /** @@ -63,6 +62,7 @@ public function get(string $key): ValidationConfigInterface __('Validation config provider for "%type" is not configured.', ['type' => $captchaType]) ); } + return $this->validationConfigProviders[$captchaType]->get(); } } diff --git a/ReCaptchaUi/composer.json b/ReCaptchaUi/composer.json index 2f0e4b81..7507d5e6 100644 --- a/ReCaptchaUi/composer.json +++ b/ReCaptchaUi/composer.json @@ -4,7 +4,8 @@ "require": { "php": "~7.3.0||~7.4.0", "magento/framework": "*", - "magento/module-re-captcha-validation-api": "*" + "magento/module-re-captcha-validation-api": "*", + "magento/module-store": "*" }, "authors": [ { diff --git a/ReCaptchaUi/etc/adminhtml/di.xml b/ReCaptchaUi/etc/adminhtml/di.xml new file mode 100644 index 00000000..50bd8e18 --- /dev/null +++ b/ReCaptchaUi/etc/adminhtml/di.xml @@ -0,0 +1,16 @@ + + + + + + + Magento\ReCaptchaUi\Model\UiConfigProvider\Proxy + + + + diff --git a/ReCaptchaUi/etc/config.xml b/ReCaptchaUi/etc/config.xml new file mode 100644 index 00000000..86eca049 --- /dev/null +++ b/ReCaptchaUi/etc/config.xml @@ -0,0 +1,16 @@ + + + + + + + https://www.google.com/recaptcha/api.js + + + + diff --git a/ReCaptchaUi/etc/frontend/di.xml b/ReCaptchaUi/etc/frontend/di.xml new file mode 100644 index 00000000..50bd8e18 --- /dev/null +++ b/ReCaptchaUi/etc/frontend/di.xml @@ -0,0 +1,16 @@ + + + + + + + Magento\ReCaptchaUi\Model\UiConfigProvider\Proxy + + + + diff --git a/ReCaptchaUi/etc/module.xml b/ReCaptchaUi/etc/module.xml index d1125400..6bf11d14 100644 --- a/ReCaptchaUi/etc/module.xml +++ b/ReCaptchaUi/etc/module.xml @@ -5,7 +5,11 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + diff --git a/ReCaptchaUi/registration.php b/ReCaptchaUi/registration.php index 8308dbd7..a5f3546b 100644 --- a/ReCaptchaUi/registration.php +++ b/ReCaptchaUi/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaUi', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaUi', __DIR__); diff --git a/ReCaptchaUser/Command/DisableReCaptchaForUserForgotPasswordCommand.php b/ReCaptchaUser/Command/DisableReCaptchaForUserForgotPasswordCommand.php index 5ccf1519..88da18b9 100644 --- a/ReCaptchaUser/Command/DisableReCaptchaForUserForgotPasswordCommand.php +++ b/ReCaptchaUser/Command/DisableReCaptchaForUserForgotPasswordCommand.php @@ -7,6 +7,7 @@ namespace Magento\ReCaptchaUser\Command; +use Magento\Framework\Console\Cli; use Magento\ReCaptchaUser\Model\DisableReCaptchaForUserForgotPassword; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -32,7 +33,7 @@ public function __construct( /** * @inheritdoc */ - protected function configure() + protected function configure(): void { $this->setName('security:recaptcha:disable-for-user-forgot-password'); $this->setDescription('Disable reCAPTCHA for admin user forgot password form'); @@ -44,8 +45,10 @@ protected function configure() * @inheritdoc * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->disableReCaptchaForUserForgotPassword->execute(); + + return Cli::RETURN_SUCCESS; } } diff --git a/ReCaptchaUser/Command/DisableReCaptchaForUserLoginCommand.php b/ReCaptchaUser/Command/DisableReCaptchaForUserLoginCommand.php index 461067e6..d462ec8f 100644 --- a/ReCaptchaUser/Command/DisableReCaptchaForUserLoginCommand.php +++ b/ReCaptchaUser/Command/DisableReCaptchaForUserLoginCommand.php @@ -7,6 +7,7 @@ namespace Magento\ReCaptchaUser\Command; +use Magento\Framework\Console\Cli; use Magento\ReCaptchaUser\Model\DisableReCaptchaForUserLogin; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; @@ -32,7 +33,7 @@ public function __construct( /** * @inheritdoc */ - protected function configure() + protected function configure(): void { $this->setName('security:recaptcha:disable-for-user-login'); $this->setDescription('Disable reCAPTCHA for admin user login form'); @@ -44,8 +45,10 @@ protected function configure() * @inheritdoc * @SuppressWarnings("PHPMD.UnusedFormalParameter") */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): int { $this->disableReCaptchaForUserLogin->execute(); + + return Cli::RETURN_SUCCESS; } } diff --git a/ReCaptchaUser/Model/DisableReCaptchaForUserForgotPassword.php b/ReCaptchaUser/Model/DisableReCaptchaForUserForgotPassword.php index 4db2e4bf..8b78ab2c 100644 --- a/ReCaptchaUser/Model/DisableReCaptchaForUserForgotPassword.php +++ b/ReCaptchaUser/Model/DisableReCaptchaForUserForgotPassword.php @@ -44,11 +44,7 @@ public function __construct( */ public function execute() { - $this->config->saveConfig( - self::XML_PATH_ENABLED, - null - ); - + $this->config->saveConfig(self::XML_PATH_ENABLED, null); $this->cacheManager->flush(['config']); } } diff --git a/ReCaptchaUser/Model/DisableReCaptchaForUserLogin.php b/ReCaptchaUser/Model/DisableReCaptchaForUserLogin.php index 160a55ae..5473e04e 100644 --- a/ReCaptchaUser/Model/DisableReCaptchaForUserLogin.php +++ b/ReCaptchaUser/Model/DisableReCaptchaForUserLogin.php @@ -42,13 +42,9 @@ public function __construct( /** * Disable reCAPTCHA for user login (causes config cache flush) */ - public function execute() + public function execute(): void { - $this->config->saveConfig( - self::XML_PATH_ENABLED, - null - ); - + $this->config->saveConfig(self::XML_PATH_ENABLED, null); $this->cacheManager->flush(['config']); } } diff --git a/ReCaptchaUser/etc/module.xml b/ReCaptchaUser/etc/module.xml index 533c7a8d..d5821113 100644 --- a/ReCaptchaUser/etc/module.xml +++ b/ReCaptchaUser/etc/module.xml @@ -5,7 +5,11 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + diff --git a/ReCaptchaUser/registration.php b/ReCaptchaUser/registration.php index 5fabe668..780d4e78 100644 --- a/ReCaptchaUser/registration.php +++ b/ReCaptchaUser/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaUser', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaUser', __DIR__); diff --git a/ReCaptchaUser/view/adminhtml/templates/recaptcha.phtml b/ReCaptchaUser/view/adminhtml/templates/recaptcha.phtml index c4528789..733d68e9 100644 --- a/ReCaptchaUser/view/adminhtml/templates/recaptcha.phtml +++ b/ReCaptchaUser/view/adminhtml/templates/recaptcha.phtml @@ -24,8 +24,7 @@ $isInvisible = !empty($config['invisible']); const scriptTag = document.getElementsByTagName('script')[0]; element.async = true; - element.src = 'https://www.google.com/recaptcha/api.js' - + '?onload=globalOnRecaptchaOnLoadCallback&render=explicit'; + element.src = '?onload=globalOnRecaptchaOnLoadCallback&render=explicit'; window.globalOnRecaptchaOnLoadCallback = function () { let token = ''; diff --git a/ReCaptchaValidation/Model/ValidationConfig.php b/ReCaptchaValidation/Model/ValidationConfig.php index f6bd5674..37e60fe9 100644 --- a/ReCaptchaValidation/Model/ValidationConfig.php +++ b/ReCaptchaValidation/Model/ValidationConfig.php @@ -45,7 +45,7 @@ public function __construct( string $privateKey, string $remoteIp, string $validationFailureMessage, - ValidationConfigExtensionInterface $extensionAttributes = null + ?ValidationConfigExtensionInterface $extensionAttributes = null ) { $this->privateKey = $privateKey; $this->remoteIp = $remoteIp; diff --git a/ReCaptchaValidation/etc/module.xml b/ReCaptchaValidation/etc/module.xml index bd577e5d..f8f7456a 100644 --- a/ReCaptchaValidation/etc/module.xml +++ b/ReCaptchaValidation/etc/module.xml @@ -5,7 +5,10 @@ * See COPYING.txt for license details. */ --> - - + + + + + + diff --git a/ReCaptchaValidation/registration.php b/ReCaptchaValidation/registration.php index 9c83d4c3..007269a3 100644 --- a/ReCaptchaValidation/registration.php +++ b/ReCaptchaValidation/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaValidation', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaValidation', __DIR__); diff --git a/ReCaptchaValidationApi/Api/ValidatorInterface.php b/ReCaptchaValidationApi/Api/ValidatorInterface.php index 6e580935..a900a165 100644 --- a/ReCaptchaValidationApi/Api/ValidatorInterface.php +++ b/ReCaptchaValidationApi/Api/ValidatorInterface.php @@ -24,8 +24,5 @@ interface ValidatorInterface * @param ValidationConfigInterface $validationConfig * @return ValidationResult */ - public function isValid( - string $reCaptchaResponse, - ValidationConfigInterface $validationConfig - ): ValidationResult; + public function isValid(string $reCaptchaResponse, ValidationConfigInterface $validationConfig): ValidationResult; } diff --git a/ReCaptchaValidationApi/etc/module.xml b/ReCaptchaValidationApi/etc/module.xml index 7a24451e..2aa44384 100644 --- a/ReCaptchaValidationApi/etc/module.xml +++ b/ReCaptchaValidationApi/etc/module.xml @@ -5,7 +5,6 @@ * See COPYING.txt for license details. */ --> - + diff --git a/ReCaptchaValidationApi/registration.php b/ReCaptchaValidationApi/registration.php index bed7ab66..6b9a4c3c 100644 --- a/ReCaptchaValidationApi/registration.php +++ b/ReCaptchaValidationApi/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaValidationApi', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaValidationApi', __DIR__); diff --git a/ReCaptchaVersion2Checkbox/Model/Adminhtml/UiConfigProvider.php b/ReCaptchaVersion2Checkbox/Model/Adminhtml/UiConfigProvider.php index feb2c014..9e332429 100644 --- a/ReCaptchaVersion2Checkbox/Model/Adminhtml/UiConfigProvider.php +++ b/ReCaptchaVersion2Checkbox/Model/Adminhtml/UiConfigProvider.php @@ -51,9 +51,7 @@ private function getPublicKey(): string */ private function getSize(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_SIZE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_SIZE); } /** @@ -63,9 +61,7 @@ private function getSize(): string */ private function getTheme(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_THEME - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_THEME); } /** @@ -75,9 +71,7 @@ private function getTheme(): string */ private function getLanguageCode(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_LANGUAGE_CODE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGE_CODE); } /** @@ -85,7 +79,7 @@ private function getLanguageCode(): string */ public function get(): array { - $config = [ + return [ 'rendering' => [ 'sitekey' => $this->getPublicKey(), 'size' => $this->getSize(), @@ -94,6 +88,5 @@ public function get(): array ], 'invisible' => false, ]; - return $config; } } diff --git a/ReCaptchaVersion2Checkbox/Model/Adminhtml/ValidationConfigProvider.php b/ReCaptchaVersion2Checkbox/Model/Adminhtml/ValidationConfigProvider.php index 96495fe6..6fe7c1c4 100644 --- a/ReCaptchaVersion2Checkbox/Model/Adminhtml/ValidationConfigProvider.php +++ b/ReCaptchaVersion2Checkbox/Model/Adminhtml/ValidationConfigProvider.php @@ -68,9 +68,7 @@ private function getPrivateKey(): string */ private function getValidationFailureMessage(): string { - return trim( - (string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION_FAILURE) - ); + return trim((string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION_FAILURE)); } /** @@ -78,8 +76,7 @@ private function getValidationFailureMessage(): string */ public function get(): ValidationConfigInterface { - /** @var ValidationConfigInterface $validationConfig */ - $validationConfig = $this->validationConfigFactory->create( + return $this->validationConfigFactory->create( [ 'privateKey' => $this->getPrivateKey(), 'remoteIp' => $this->remoteAddress->getRemoteAddress(), @@ -87,6 +84,5 @@ public function get(): ValidationConfigInterface 'extensionAttributes' => null, ] ); - return $validationConfig; } } diff --git a/ReCaptchaVersion2Checkbox/Model/Frontend/UiConfigProvider.php b/ReCaptchaVersion2Checkbox/Model/Frontend/UiConfigProvider.php index bdc4b7f5..2cb04d99 100644 --- a/ReCaptchaVersion2Checkbox/Model/Frontend/UiConfigProvider.php +++ b/ReCaptchaVersion2Checkbox/Model/Frontend/UiConfigProvider.php @@ -52,10 +52,7 @@ private function getPublicKey(): string */ private function getSize(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_SIZE, - ScopeInterface::SCOPE_WEBSITE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_SIZE, ScopeInterface::SCOPE_WEBSITE); } /** @@ -65,10 +62,7 @@ private function getSize(): string */ private function getTheme(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_THEME, - ScopeInterface::SCOPE_WEBSITE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_THEME, ScopeInterface::SCOPE_WEBSITE); } /** @@ -78,10 +72,7 @@ private function getTheme(): string */ private function getLanguageCode(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_LANGUAGE_CODE, - ScopeInterface::SCOPE_STORE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGE_CODE, ScopeInterface::SCOPE_STORE); } /** @@ -91,7 +82,7 @@ private function getLanguageCode(): string */ public function get(): array { - $config = [ + return [ 'rendering' => [ 'sitekey' => $this->getPublicKey(), 'size' => $this->getSize(), @@ -100,6 +91,5 @@ public function get(): array ], 'invisible' => false, ]; - return $config; } } diff --git a/ReCaptchaVersion2Checkbox/Model/Frontend/ValidationConfigProvider.php b/ReCaptchaVersion2Checkbox/Model/Frontend/ValidationConfigProvider.php index 136a7dc3..a769c428 100644 --- a/ReCaptchaVersion2Checkbox/Model/Frontend/ValidationConfigProvider.php +++ b/ReCaptchaVersion2Checkbox/Model/Frontend/ValidationConfigProvider.php @@ -81,8 +81,7 @@ private function getValidationFailureMessage(): string */ public function get(): ValidationConfigInterface { - /** @var ValidationConfigInterface $validationConfig */ - $validationConfig = $this->validationConfigFactory->create( + return $this->validationConfigFactory->create( [ 'privateKey' => $this->getPrivateKey(), 'remoteIp' => $this->remoteAddress->getRemoteAddress(), @@ -90,6 +89,5 @@ public function get(): ValidationConfigInterface 'extensionAttributes' => null, ] ); - return $validationConfig; } } diff --git a/ReCaptchaVersion2Checkbox/etc/module.xml b/ReCaptchaVersion2Checkbox/etc/module.xml index 19a79a04..3fc37d71 100644 --- a/ReCaptchaVersion2Checkbox/etc/module.xml +++ b/ReCaptchaVersion2Checkbox/etc/module.xml @@ -5,7 +5,12 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + + diff --git a/ReCaptchaVersion2Checkbox/registration.php b/ReCaptchaVersion2Checkbox/registration.php index 725347e0..f5fcbad7 100644 --- a/ReCaptchaVersion2Checkbox/registration.php +++ b/ReCaptchaVersion2Checkbox/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaVersion2Checkbox', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaVersion2Checkbox', __DIR__); diff --git a/ReCaptchaVersion2Invisible/Model/Adminhtml/UiConfigProvider.php b/ReCaptchaVersion2Invisible/Model/Adminhtml/UiConfigProvider.php index c592e70d..987cd66f 100644 --- a/ReCaptchaVersion2Invisible/Model/Adminhtml/UiConfigProvider.php +++ b/ReCaptchaVersion2Invisible/Model/Adminhtml/UiConfigProvider.php @@ -41,9 +41,7 @@ public function __construct( */ private function getLanguageCode(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_LANGUAGE_CODE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGE_CODE); } /** @@ -63,9 +61,7 @@ private function getPublicKey(): string */ private function getInvisibleBadgePosition(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_POSITION - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_POSITION); } /** @@ -75,9 +71,7 @@ private function getInvisibleBadgePosition(): string */ private function getTheme(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_THEME - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_THEME); } /** @@ -85,7 +79,7 @@ private function getTheme(): string */ public function get(): array { - $config = [ + return [ 'rendering' => [ 'sitekey' => $this->getPublicKey(), 'badge' => $this->getInvisibleBadgePosition(), @@ -95,6 +89,5 @@ public function get(): array ], 'invisible' => true, ]; - return $config; } } diff --git a/ReCaptchaVersion2Invisible/Model/Adminhtml/ValidationConfigProvider.php b/ReCaptchaVersion2Invisible/Model/Adminhtml/ValidationConfigProvider.php index c6184081..576a02a5 100644 --- a/ReCaptchaVersion2Invisible/Model/Adminhtml/ValidationConfigProvider.php +++ b/ReCaptchaVersion2Invisible/Model/Adminhtml/ValidationConfigProvider.php @@ -58,9 +58,7 @@ public function __construct( */ private function getValidationFailureMessage(): string { - return trim( - (string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION_FAILURE) - ); + return trim((string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION_FAILURE)); } /** @@ -78,8 +76,7 @@ private function getPrivateKey(): string */ public function get(): ValidationConfigInterface { - /** @var ValidationConfigInterface $validationConfig */ - $validationConfig = $this->validationConfigFactory->create( + return $this->validationConfigFactory->create( [ 'privateKey' => $this->getPrivateKey(), 'remoteIp' => $this->remoteAddress->getRemoteAddress(), @@ -87,6 +84,5 @@ public function get(): ValidationConfigInterface 'extensionAttributes' => null, ] ); - return $validationConfig; } } diff --git a/ReCaptchaVersion2Invisible/Model/Frontend/UiConfigProvider.php b/ReCaptchaVersion2Invisible/Model/Frontend/UiConfigProvider.php index 4e84c44f..4457a75f 100644 --- a/ReCaptchaVersion2Invisible/Model/Frontend/UiConfigProvider.php +++ b/ReCaptchaVersion2Invisible/Model/Frontend/UiConfigProvider.php @@ -42,10 +42,7 @@ public function __construct( */ private function getLanguageCode(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_LANGUAGE_CODE, - ScopeInterface::SCOPE_STORE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGE_CODE, ScopeInterface::SCOPE_STORE); } /** @@ -55,10 +52,7 @@ private function getLanguageCode(): string */ private function getInvisibleBadgePosition(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_POSITION, - ScopeInterface::SCOPE_WEBSITE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_POSITION, ScopeInterface::SCOPE_WEBSITE); } /** @@ -78,10 +72,7 @@ private function getPublicKey(): string */ private function getTheme(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_THEME, - ScopeInterface::SCOPE_WEBSITE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_THEME, ScopeInterface::SCOPE_WEBSITE); } /** @@ -89,7 +80,7 @@ private function getTheme(): string */ public function get(): array { - $config = [ + return [ 'rendering' => [ 'sitekey' => $this->getPublicKey(), 'badge' => $this->getInvisibleBadgePosition(), @@ -99,6 +90,5 @@ public function get(): array ], 'invisible' => true, ]; - return $config; } } diff --git a/ReCaptchaVersion2Invisible/Model/Frontend/ValidationConfigProvider.php b/ReCaptchaVersion2Invisible/Model/Frontend/ValidationConfigProvider.php index f1208ba0..67872bd6 100644 --- a/ReCaptchaVersion2Invisible/Model/Frontend/ValidationConfigProvider.php +++ b/ReCaptchaVersion2Invisible/Model/Frontend/ValidationConfigProvider.php @@ -79,8 +79,7 @@ private function getPrivateKey(): string */ public function get(): ValidationConfigInterface { - /** @var ValidationConfigInterface $validationConfig */ - $validationConfig = $this->validationConfigFactory->create( + return $this->validationConfigFactory->create( [ 'privateKey' => $this->getPrivateKey(), 'remoteIp' => $this->remoteAddress->getRemoteAddress(), @@ -88,6 +87,5 @@ public function get(): ValidationConfigInterface 'extensionAttributes' => null, ] ); - return $validationConfig; } } diff --git a/ReCaptchaVersion2Invisible/etc/module.xml b/ReCaptchaVersion2Invisible/etc/module.xml index 348088be..52b384d8 100644 --- a/ReCaptchaVersion2Invisible/etc/module.xml +++ b/ReCaptchaVersion2Invisible/etc/module.xml @@ -5,7 +5,12 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + + diff --git a/ReCaptchaVersion2Invisible/registration.php b/ReCaptchaVersion2Invisible/registration.php index 69a4a5c8..9e38bc35 100644 --- a/ReCaptchaVersion2Invisible/registration.php +++ b/ReCaptchaVersion2Invisible/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaVersion2Invisible', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaVersion2Invisible', __DIR__); diff --git a/ReCaptchaVersion3Invisible/Model/Adminhtml/UiConfigProvider.php b/ReCaptchaVersion3Invisible/Model/Adminhtml/UiConfigProvider.php index 565b84df..9d1821eb 100644 --- a/ReCaptchaVersion3Invisible/Model/Adminhtml/UiConfigProvider.php +++ b/ReCaptchaVersion3Invisible/Model/Adminhtml/UiConfigProvider.php @@ -51,9 +51,7 @@ private function getPublicKey(): string */ private function getInvisibleBadgePosition(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_POSITION - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_POSITION); } /** @@ -63,9 +61,7 @@ private function getInvisibleBadgePosition(): string */ private function getTheme(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_THEME - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_THEME); } /** @@ -75,9 +71,7 @@ private function getTheme(): string */ private function getLanguageCode(): string { - return (string)$this->scopeConfig->getValue( - self::XML_PATH_LANGUAGE_CODE - ); + return (string)$this->scopeConfig->getValue(self::XML_PATH_LANGUAGE_CODE); } /** @@ -85,7 +79,7 @@ private function getLanguageCode(): string */ public function get(): array { - $config = [ + return [ 'rendering' => [ 'sitekey' => $this->getPublicKey(), 'badge' => $this->getInvisibleBadgePosition(), @@ -95,6 +89,5 @@ public function get(): array ], 'invisible' => true, ]; - return $config; } } diff --git a/ReCaptchaVersion3Invisible/Model/Adminhtml/ValidationConfigProvider.php b/ReCaptchaVersion3Invisible/Model/Adminhtml/ValidationConfigProvider.php index b93bc4f0..89c77f62 100644 --- a/ReCaptchaVersion3Invisible/Model/Adminhtml/ValidationConfigProvider.php +++ b/ReCaptchaVersion3Invisible/Model/Adminhtml/ValidationConfigProvider.php @@ -78,9 +78,7 @@ private function getPrivateKey(): string */ private function getValidationFailureMessage(): string { - return trim( - (string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION_FAILURE) - ); + return trim((string)$this->scopeConfig->getValue(self::XML_PATH_VALIDATION_FAILURE)); } /** @@ -92,9 +90,7 @@ private function getValidationFailureMessage(): string */ private function getScoreThreshold(): float { - return min(1.0, max(0.1, (float)$this->scopeConfig->getValue( - self::XML_PATH_SCORE_THRESHOLD - ))); + return min(1.0, max(0.1, (float)$this->scopeConfig->getValue(self::XML_PATH_SCORE_THRESHOLD))); } /** @@ -104,8 +100,8 @@ public function get(): ValidationConfigInterface { $extensionAttributes = $this->validationConfigExtensionFactory->create(); $extensionAttributes->setData('scoreThreshold', $this->getScoreThreshold()); - /** @var ValidationConfigInterface $validationConfig */ - $validationConfig = $this->validationConfigFactory->create( + + return $this->validationConfigFactory->create( [ 'privateKey' => $this->getPrivateKey(), 'remoteIp' => $this->remoteAddress->getRemoteAddress(), @@ -113,6 +109,5 @@ public function get(): ValidationConfigInterface 'extensionAttributes' => $extensionAttributes, ] ); - return $validationConfig; } } diff --git a/ReCaptchaVersion3Invisible/etc/module.xml b/ReCaptchaVersion3Invisible/etc/module.xml index 84efbd88..d63950a4 100644 --- a/ReCaptchaVersion3Invisible/etc/module.xml +++ b/ReCaptchaVersion3Invisible/etc/module.xml @@ -5,7 +5,12 @@ * See COPYING.txt for license details. */ --> - - + + + + + + + + diff --git a/ReCaptchaVersion3Invisible/registration.php b/ReCaptchaVersion3Invisible/registration.php index a69eb3ad..3e5bf83b 100644 --- a/ReCaptchaVersion3Invisible/registration.php +++ b/ReCaptchaVersion3Invisible/registration.php @@ -5,8 +5,6 @@ */ declare(strict_types=1); -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, - 'Magento_ReCaptchaVersion3Invisible', - __DIR__ -); +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ReCaptchaVersion3Invisible', __DIR__);