1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @copyright Copyright (c) Flipbox Digital Limited |
5
|
|
|
* @license https://flipboxfactory.com/software/organization/license |
6
|
|
|
* @link https://www.flipboxfactory.com/software/organization/ |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace flipbox\organizations\models; |
10
|
|
|
|
11
|
|
|
use Craft; |
12
|
|
|
use craft\validators\UriFormatValidator; |
13
|
|
|
use flipbox\craft\ember\helpers\ModelHelper; |
14
|
|
|
use flipbox\craft\ember\models\SiteAttributeTrait; |
15
|
|
|
use yii\base\Model; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Flipbox Factory <[email protected]> |
19
|
|
|
* @since 1.0.0 |
20
|
|
|
*/ |
21
|
|
|
class SiteSettings extends Model implements SiteSettingsInterface |
22
|
|
|
{ |
23
|
|
|
use SiteAttributeTrait; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @var boolean Has URLs |
27
|
|
|
*/ |
28
|
|
|
public $enabledByDefault = true; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var boolean Has URLs |
32
|
|
|
*/ |
33
|
|
|
public $hasUrls = false; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* @var string URL format |
37
|
|
|
*/ |
38
|
|
|
public $uriFormat; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @var string Template |
42
|
|
|
*/ |
43
|
|
|
public $template; |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @inheritdoc |
47
|
|
|
*/ |
48
|
|
|
public function attributes() |
49
|
|
|
{ |
50
|
|
|
return array_merge( |
51
|
|
|
parent::attributes(), |
52
|
|
|
$this->siteAttributes() |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @return bool |
58
|
|
|
*/ |
59
|
|
|
public function hasUrls(): bool |
60
|
|
|
{ |
61
|
|
|
return (bool)$this->hasUrls; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public function getUriFormat() |
68
|
|
|
{ |
69
|
|
|
return $this->uriFormat; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return string |
74
|
|
|
*/ |
75
|
|
|
public function getTemplate() |
76
|
|
|
{ |
77
|
|
|
return $this->template; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @inheritdoc |
82
|
|
|
*/ |
83
|
|
|
public function attributeLabels() |
84
|
|
|
{ |
85
|
|
|
return array_merge( |
86
|
|
|
parent::attributeLabels(), |
87
|
|
|
$this->siteAttributeLabels(), |
88
|
|
|
[ |
89
|
|
|
'hasUrls' => Craft::t('app', 'Has Urls'), |
90
|
|
|
'uriFormat' => Craft::t('app', 'URI Format'), |
91
|
|
|
'template' => Craft::t('app', 'Template'), |
92
|
|
|
'enabledByDefault' => Craft::t('app', 'Enabled by Default') |
93
|
|
|
] |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @inheritdoc |
99
|
|
|
*/ |
100
|
|
|
public function rules() |
101
|
|
|
{ |
102
|
|
|
return array_merge( |
103
|
|
|
parent::rules(), |
104
|
|
|
$this->siteRules(), |
105
|
|
|
[ |
106
|
|
|
[ |
107
|
|
|
[ |
108
|
|
|
'template' |
109
|
|
|
], |
110
|
|
|
'string', |
111
|
|
|
'max' => 500 |
112
|
|
|
], |
113
|
|
|
[ |
114
|
|
|
[ |
115
|
|
|
'uriFormat' |
116
|
|
|
], |
117
|
|
|
UriFormatValidator::class |
118
|
|
|
], |
119
|
|
|
[ |
120
|
|
|
[ |
121
|
|
|
'enabledByDefault', |
122
|
|
|
'hasUrls', |
123
|
|
|
'uriFormat', |
124
|
|
|
'template' |
125
|
|
|
], |
126
|
|
|
'safe', |
127
|
|
|
'on' => [ |
128
|
|
|
ModelHelper::SCENARIO_DEFAULT |
|
|
|
|
129
|
|
|
] |
130
|
|
|
], |
131
|
|
|
[ |
132
|
|
|
[ |
133
|
|
|
'uriFormat', |
134
|
|
|
'template' |
135
|
|
|
], |
136
|
|
|
'required', |
137
|
|
|
'when' => function ($model) { |
138
|
|
|
return $model->hasUrls == true; |
139
|
|
|
}, |
140
|
|
|
'enableClientValidation' => false |
141
|
|
|
] |
142
|
|
|
] |
143
|
|
|
); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.