|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2019. Volodymyr Hryvinskyi. All rights reserved. |
|
4
|
|
|
* @author: <mailto:[email protected]> |
|
5
|
|
|
* @github: <https://github.com/hryvinskyi> |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Hryvinskyi\InvisibleCaptcha\Helper\Config; |
|
11
|
|
|
|
|
12
|
|
|
use Hryvinskyi\InvisibleCaptcha\Helper\AbstractConfig; |
|
13
|
|
|
use Magento\Store\Model\ScopeInterface; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class Backend |
|
17
|
|
|
*/ |
|
18
|
|
|
class Backend extends AbstractConfig |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Configuration path |
|
22
|
|
|
*/ |
|
23
|
|
|
const CONFIG_PATH_BACKEND_ENABLED = 'hryvinskyi_invisible_captcha/backend/enabled'; |
|
24
|
|
|
const CONFIG_PATH_BACKEND_ENABLED_LOGIN = 'hryvinskyi_invisible_captcha/backend/enabledLogin'; |
|
25
|
|
|
const CONFIG_PATH_BACKEND_SCORE_THRESHOLD_LOGIN = 'hryvinskyi_invisible_captcha/backend/scoreThresholdLogin'; |
|
26
|
|
|
const CONFIG_PATH_BACKEND_ENABLED_FORGOT = 'hryvinskyi_invisible_captcha/backend/enabledForgot'; |
|
27
|
|
|
const CONFIG_PATH_BACKEND_SCORE_THRESHOLD_FORGOT = 'hryvinskyi_invisible_captcha/backend/scoreThresholdForgot'; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Is google recaptcha enable backend |
|
31
|
|
|
* |
|
32
|
|
|
* @param string $scopeType |
|
33
|
|
|
* @param mixed $scopeCode |
|
34
|
|
|
* |
|
35
|
|
|
* @return bool |
|
36
|
|
|
*/ |
|
37
|
|
|
public function hasEnabled( |
|
38
|
|
|
string $scopeType = ScopeInterface::SCOPE_WEBSITES, |
|
39
|
|
|
$scopeCode = null |
|
40
|
|
|
): bool { |
|
41
|
|
|
return $this->scopeConfig->isSetFlag( |
|
42
|
|
|
self::CONFIG_PATH_BACKEND_ENABLED, |
|
43
|
|
|
$scopeType, |
|
44
|
|
|
$scopeCode |
|
45
|
|
|
); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Is google recaptcha enable login |
|
50
|
|
|
* |
|
51
|
|
|
* @param string $scopeType |
|
52
|
|
|
* @param mixed $scopeCode |
|
53
|
|
|
* |
|
54
|
|
|
* @return bool |
|
55
|
|
|
*/ |
|
56
|
|
|
public function hasEnabledLogin( |
|
57
|
|
|
string $scopeType = ScopeInterface::SCOPE_WEBSITES, |
|
58
|
|
|
$scopeCode = null |
|
59
|
|
|
): bool { |
|
60
|
|
|
return $this->scopeConfig->isSetFlag( |
|
61
|
|
|
self::CONFIG_PATH_BACKEND_ENABLED_LOGIN, |
|
62
|
|
|
$scopeType, |
|
63
|
|
|
$scopeCode |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Get google recaptcha score threshold login |
|
69
|
|
|
* |
|
70
|
|
|
* @param string $scopeType |
|
71
|
|
|
* @param mixed $scopeCode |
|
72
|
|
|
* |
|
73
|
|
|
* @return float |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getScoreThresholdLogin( |
|
76
|
|
|
string $scopeType = ScopeInterface::SCOPE_WEBSITES, |
|
77
|
|
|
$scopeCode = null |
|
78
|
|
|
): float { |
|
79
|
|
|
return (float)$this->scopeConfig->getValue( |
|
80
|
|
|
self::CONFIG_PATH_BACKEND_SCORE_THRESHOLD_LOGIN, |
|
81
|
|
|
$scopeType, |
|
82
|
|
|
$scopeCode |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Is google recaptcha enable forgot |
|
88
|
|
|
* |
|
89
|
|
|
* @param string $scopeType |
|
90
|
|
|
* @param mixed $scopeCode |
|
91
|
|
|
* |
|
92
|
|
|
* @return bool |
|
93
|
|
|
*/ |
|
94
|
|
|
public function hasEnabledForgot( |
|
95
|
|
|
string $scopeType = ScopeInterface::SCOPE_WEBSITES, |
|
96
|
|
|
$scopeCode = null |
|
97
|
|
|
): bool { |
|
98
|
|
|
return $this->scopeConfig->isSetFlag( |
|
99
|
|
|
self::CONFIG_PATH_BACKEND_ENABLED_FORGOT, |
|
100
|
|
|
$scopeType, |
|
101
|
|
|
$scopeCode |
|
102
|
|
|
); |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* Get google recaptcha score threshold forgot |
|
107
|
|
|
* |
|
108
|
|
|
* @param string $scopeType |
|
109
|
|
|
* @param mixed $scopeCode |
|
110
|
|
|
* |
|
111
|
|
|
* @return float |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getScoreThresholdForgot( |
|
114
|
|
|
string $scopeType = ScopeInterface::SCOPE_WEBSITES, |
|
115
|
|
|
$scopeCode = null |
|
116
|
|
|
): float { |
|
117
|
|
|
return (float)$this->scopeConfig->getValue( |
|
118
|
|
|
self::CONFIG_PATH_BACKEND_SCORE_THRESHOLD_FORGOT, |
|
119
|
|
|
$scopeType, |
|
120
|
|
|
$scopeCode |
|
121
|
|
|
); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Disable config path |
|
126
|
|
|
* |
|
127
|
|
|
* @return string |
|
128
|
|
|
*/ |
|
129
|
|
|
public function disableConfigPath(): string |
|
130
|
|
|
{ |
|
131
|
|
|
return self::CONFIG_PATH_BACKEND_ENABLED; |
|
132
|
|
|
} |
|
133
|
|
|
} |
|
134
|
|
|
|