| Total Complexity | 7 |
| Total Lines | 54 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | class FormUserSettings extends Model |
||
| 12 | { |
||
| 13 | public $registrationType; |
||
| 14 | public $captchaOnLogin; |
||
| 15 | public $captchaOnRegister; |
||
| 16 | |||
| 17 | private $_config; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * FormUserSettings constructor. Pass configs inside the model |
||
| 21 | * @param array|null $config |
||
| 22 | */ |
||
| 23 | public function __construct(array $config = null) |
||
| 24 | { |
||
| 25 | $this->_config = $config; |
||
| 26 | parent::__construct(); |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Load configs from app data |
||
| 31 | */ |
||
| 32 | public function before() |
||
| 33 | { |
||
| 34 | if ($this->_config === null) { |
||
| 35 | return; |
||
| 36 | } |
||
| 37 | foreach ($this->_config as $property => $value) { |
||
| 38 | if (property_exists($this, $property)) { |
||
| 39 | $this->$property = $value; |
||
| 40 | } |
||
| 41 | } |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Form display labels |
||
| 46 | * @return array |
||
| 47 | */ |
||
| 48 | public function labels(): array |
||
| 49 | { |
||
| 50 | return [ |
||
| 51 | 'registrationType' => __('Registration type'), |
||
| 52 | 'captchaOnLogin' => __('Captcha on login'), |
||
| 53 | 'captchaOnRegister' => __('Captcha on registration') |
||
| 54 | ]; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * Validation rules |
||
| 59 | * @return array |
||
| 60 | */ |
||
| 61 | public function rules(): array |
||
| 65 | ]; |
||
| 66 | } |
||
| 67 | } |
||
| 68 |