1 | <?php |
||
2 | /** |
||
3 | * SEOmatic plugin for Craft CMS 3.x |
||
4 | * |
||
5 | * A turnkey SEO implementation for Craft CMS that is comprehensive, powerful, |
||
6 | * and flexible |
||
7 | * |
||
8 | * @link https://nystudio107.com |
||
9 | * @copyright Copyright (c) 2017 nystudio107 |
||
10 | */ |
||
11 | |||
12 | namespace nystudio107\seomatic\models; |
||
13 | |||
14 | use nystudio107\seomatic\base\VarsModel; |
||
15 | |||
16 | /** |
||
17 | * @inheritdoc |
||
18 | * |
||
19 | * @author nystudio107 |
||
20 | * @package Seomatic |
||
21 | * @since 3.0.0 |
||
22 | */ |
||
23 | class MetaBundleSettings extends VarsModel |
||
24 | { |
||
25 | // Static Methods |
||
26 | // ========================================================================= |
||
27 | |||
28 | /** |
||
29 | * @param array $config |
||
30 | * |
||
31 | * @return null|MetaBundleSettings |
||
32 | */ |
||
33 | public static function create(array $config = []) |
||
34 | { |
||
35 | return new MetaBundleSettings($config); |
||
36 | } |
||
37 | |||
38 | // Public Properties |
||
39 | // ========================================================================= |
||
40 | |||
41 | /** |
||
42 | * @var string The schema.org general type |
||
43 | */ |
||
44 | public $siteType = 'CreativeWork'; |
||
45 | |||
46 | /** |
||
47 | * @var string The schema.org sub-type |
||
48 | */ |
||
49 | public $siteSubType = 'WebPage'; |
||
50 | |||
51 | /** |
||
52 | * @var string The schema.org specific type |
||
53 | */ |
||
54 | public $siteSpecificType = ''; |
||
55 | |||
56 | /** |
||
57 | * @var string The source that the SEO title should come from |
||
58 | */ |
||
59 | public $seoTitleSource; |
||
60 | |||
61 | /** |
||
62 | * @var string the field handle that the SEO title is pulled from |
||
63 | */ |
||
64 | public $seoTitleField; |
||
65 | |||
66 | /** |
||
67 | * @var string The source that the Twitter site name position should come from |
||
68 | */ |
||
69 | public $siteNamePositionSource; |
||
70 | |||
71 | /** |
||
72 | * @var string The source that the SEO description should come from |
||
73 | */ |
||
74 | public $seoDescriptionSource; |
||
75 | |||
76 | /** |
||
77 | * @var string the field handle that the SEO description is pulled from |
||
78 | */ |
||
79 | public $seoDescriptionField; |
||
80 | |||
81 | /** |
||
82 | * @var string The source that the SEO keywords should come from |
||
83 | */ |
||
84 | public $seoKeywordsSource; |
||
85 | |||
86 | /** |
||
87 | * @var string the field handle that the SEO keywords is pulled from |
||
88 | */ |
||
89 | public $seoKeywordsField; |
||
90 | |||
91 | /** |
||
92 | * @var int[] The AssetIDs for the SEO Image |
||
93 | */ |
||
94 | public $seoImageIds = []; |
||
95 | |||
96 | /** |
||
97 | * @var string The source that the SEO image should come from |
||
98 | */ |
||
99 | public $seoImageSource = ''; |
||
100 | |||
101 | /** |
||
102 | * @var string The field handle that SEO Image is pulled from |
||
103 | */ |
||
104 | public $seoImageField = ''; |
||
105 | |||
106 | /** |
||
107 | * @var bool Whether the SEO image should be automatically transformed into an appropriate format |
||
108 | */ |
||
109 | public $seoImageTransform = true; |
||
110 | |||
111 | /** |
||
112 | * @var bool The transform mode to use for SEO image transforms |
||
113 | */ |
||
114 | public $seoImageTransformMode = 'crop'; |
||
115 | |||
116 | /** |
||
117 | * @var string The source that the SEO image description should come from |
||
118 | */ |
||
119 | public $seoImageDescriptionSource; |
||
120 | |||
121 | /** |
||
122 | * @var string the field handle that the SEO image description is pulled from |
||
123 | */ |
||
124 | public $seoImageDescriptionField; |
||
125 | |||
126 | /** |
||
127 | * @var string The source that the Twitter creator should come from |
||
128 | */ |
||
129 | public $twitterCreatorSource; |
||
130 | |||
131 | /** |
||
132 | * @var string The field handle that the Twitter creator is pulled from |
||
133 | */ |
||
134 | public $twitterCreatorField; |
||
135 | |||
136 | /** |
||
137 | * @var string The source that the Twitter title should come from |
||
138 | */ |
||
139 | public $twitterTitleSource; |
||
140 | |||
141 | /** |
||
142 | * @var string The field handle that the Twitter title is pulled from |
||
143 | */ |
||
144 | public $twitterTitleField; |
||
145 | |||
146 | /** |
||
147 | * @var string The source that the Twitter site name position should come from |
||
148 | */ |
||
149 | public $twitterSiteNamePositionSource; |
||
150 | |||
151 | /** |
||
152 | * @var string The source that the Twitter description should come from |
||
153 | */ |
||
154 | public $twitterDescriptionSource; |
||
155 | |||
156 | /** |
||
157 | * @var string the field handle that the Twitter description is pulled from |
||
158 | */ |
||
159 | public $twitterDescriptionField; |
||
160 | |||
161 | /** |
||
162 | * @var int[] The AssetIDs for the Twitter Image |
||
163 | */ |
||
164 | public $twitterImageIds = []; |
||
165 | |||
166 | /** |
||
167 | * @var string The source that the Twitter image should come from |
||
168 | */ |
||
169 | public $twitterImageSource = ''; |
||
170 | |||
171 | /** |
||
172 | * @var string The field handle that Twitter Image to be pulled from |
||
173 | */ |
||
174 | public $twitterImageField = ''; |
||
175 | |||
176 | /** |
||
177 | * @var bool Whether the Twitter image should be automatically transformed into an appropriate format |
||
178 | */ |
||
179 | public $twitterImageTransform = true; |
||
180 | |||
181 | /** |
||
182 | * @var bool The transform mode to use for Twitter image transforms |
||
183 | */ |
||
184 | public $twitterImageTransformMode = 'crop'; |
||
185 | |||
186 | /** |
||
187 | * @var string The source that the Twitter image description should come from |
||
188 | */ |
||
189 | public $twitterImageDescriptionSource; |
||
190 | |||
191 | /** |
||
192 | * @var string the field handle that the Twitter image description is pulled from |
||
193 | */ |
||
194 | public $twitterImageDescriptionField; |
||
195 | |||
196 | /** |
||
197 | * @var string The source that the Facebook OG title should come from |
||
198 | */ |
||
199 | public $ogTitleSource; |
||
200 | |||
201 | /** |
||
202 | * @var string the field handle that the Facebook OG title is pulled from |
||
203 | */ |
||
204 | public $ogTitleField; |
||
205 | |||
206 | /** |
||
207 | * @var string The source that the Facebook OG site name position should come from |
||
208 | */ |
||
209 | public $ogSiteNamePositionSource; |
||
210 | |||
211 | /** |
||
212 | * @var string The source that the Facebook OG description should come from |
||
213 | */ |
||
214 | public $ogDescriptionSource; |
||
215 | |||
216 | /** |
||
217 | * @var string the field handle that the Facebook OG description is pulled from |
||
218 | */ |
||
219 | public $ogDescriptionField; |
||
220 | |||
221 | /** |
||
222 | * @var int[] The AssetIDs for the Facebook OG Image |
||
223 | */ |
||
224 | public $ogImageIds = []; |
||
225 | |||
226 | /** |
||
227 | * @var string The source that the OpenGraph image should come from |
||
228 | */ |
||
229 | public $ogImageSource = ''; |
||
230 | |||
231 | /** |
||
232 | * @var string The field handle that OpenGraph Image to be pulled from |
||
233 | */ |
||
234 | public $ogImageField = ''; |
||
235 | |||
236 | /** |
||
237 | * @var bool Whether the OpenGraph image should be automatically transformed into an appropriate format |
||
238 | */ |
||
239 | public $ogImageTransform = true; |
||
240 | |||
241 | /** |
||
242 | * @var bool The transform mode to use for OpenGraph image transforms |
||
243 | */ |
||
244 | public $ogImageTransformMode = 'crop'; |
||
245 | |||
246 | /** |
||
247 | * @var string The source that the Facebook OG image description should come from |
||
248 | */ |
||
249 | public $ogImageDescriptionSource; |
||
250 | |||
251 | /** |
||
252 | * @var string the field handle that the Facebook OG image description is pulled from |
||
253 | */ |
||
254 | public $ogImageDescriptionField; |
||
255 | |||
256 | // Public Methods |
||
257 | // ========================================================================= |
||
258 | |||
259 | /** |
||
260 | * @inheritdoc |
||
261 | */ |
||
262 | public function init() |
||
263 | { |
||
264 | parent::init(); |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * @inheritdoc |
||
269 | */ |
||
270 | public function rules(): array |
||
271 | { |
||
272 | return [ |
||
273 | [ |
||
274 | [ |
||
275 | 'siteType', |
||
276 | 'siteSubType', |
||
277 | 'siteSpecificType', |
||
278 | |||
279 | 'seoTitleSource', |
||
280 | 'seoTitleField', |
||
281 | 'siteNamePositionSource', |
||
282 | 'seoDescriptionSource', |
||
283 | 'seoDescriptionField', |
||
284 | 'seoKeywordsSource', |
||
285 | 'seoKeywordsField', |
||
286 | 'seoImageSource', |
||
287 | 'seoImageField', |
||
288 | 'seoImageDescriptionSource', |
||
289 | 'seoImageDescriptionField', |
||
290 | |||
291 | 'twitterCreatorSource', |
||
292 | 'twitterCreatorField', |
||
293 | 'twitterTitleSource', |
||
294 | 'twitterTitleField', |
||
295 | 'twitterSiteNamePositionSource', |
||
296 | 'twitterDescriptionSource', |
||
297 | 'twitterDescriptionField', |
||
298 | 'twitterImageSource', |
||
299 | 'twitterImageField', |
||
300 | 'twitterImageDescriptionSource', |
||
301 | 'twitterImageDescriptionField', |
||
302 | |||
303 | 'ogTitleSource', |
||
304 | 'ogTitleField', |
||
305 | 'ogSiteNamePositionSource', |
||
306 | 'ogDescriptionSource', |
||
307 | 'ogDescriptionField', |
||
308 | 'ogImageSource', |
||
309 | 'ogImageField', |
||
310 | 'ogImageDescriptionSource', |
||
311 | 'ogImageDescriptionField', |
||
312 | ], |
||
313 | 'string' |
||
314 | ], |
||
315 | [ |
||
316 | ['seoImageTransformMode', 'twitterImageTransformMode', 'ogImageTransformMode'], |
||
317 | 'in', |
||
318 | 'range' => [ |
||
319 | 'stretch', |
||
320 | 'fit', |
||
321 | 'crop', |
||
322 | ], |
||
323 | ], |
||
324 | [ |
||
325 | [ |
||
326 | 'seoImageTransform', |
||
327 | 'twitterImageTransform', |
||
328 | 'ogImageTransform', |
||
329 | ], |
||
330 | 'boolean' |
||
331 | ], |
||
332 | [ |
||
333 | ['seoImageSource', 'twitterImageSource', 'ogImageSource'], 'in', 'range' => [ |
||
334 | 'sameAsSeo', |
||
335 | 'fromField', |
||
336 | 'fromAsset', |
||
337 | 'fromUrl', |
||
338 | ], |
||
339 | ], |
||
340 | [ |
||
341 | ['seoTitleSource', 'twitterTitleSource', 'ogTitleSource'], 'in', 'range' => [ |
||
342 | 'sameAsSeo', |
||
343 | 'fromField', |
||
344 | 'fromCustom', |
||
345 | ], |
||
346 | ], |
||
347 | [ |
||
348 | ['twitterCreatorSource'], 'in', 'range' => [ |
||
349 | 'sameAsSite', |
||
350 | 'sameAsSiteTwitter', |
||
351 | 'fromUserField', |
||
352 | 'fromCustom', |
||
353 | ], |
||
354 | ], |
||
355 | [ |
||
356 | ['siteNamePositionSource', 'twitterSiteNamePositionSource', 'ogSiteNamePositionSource'], 'in', 'range' => [ |
||
357 | 'sameAsSeo', |
||
358 | 'sameAsGlobal', |
||
359 | 'fromCustom', |
||
360 | ], |
||
361 | ], |
||
362 | [ |
||
363 | ['seoDescriptionSource', 'twitterDescriptionSource', 'ogDescriptionSource'], 'in', 'range' => [ |
||
364 | 'sameAsSeo', |
||
365 | 'fromField', |
||
366 | 'summaryFromField', |
||
367 | 'fromCustom', |
||
368 | ], |
||
369 | ], |
||
370 | [ |
||
371 | ['seoKeywordsSource'], 'in', 'range' => [ |
||
372 | 'sameAsSeo', |
||
373 | 'fromField', |
||
374 | 'keywordsFromField', |
||
375 | 'fromCustom', |
||
376 | ], |
||
377 | ], |
||
378 | [ |
||
379 | ['seoImageDescriptionSource', 'twitterImageDescriptionSource', 'ogImageDescriptionSource'], 'in', 'range' => [ |
||
380 | 'sameAsSeo', |
||
381 | 'fromField', |
||
382 | 'summaryFromField', |
||
383 | 'fromCustom', |
||
384 | ], |
||
385 | ], |
||
386 | [ |
||
387 | [ |
||
388 | 'seoImageIds', |
||
389 | 'twitterImageIds', |
||
390 | 'ogImageIds', |
||
391 | ], |
||
392 | 'each', 'rule' => ['integer'], |
||
393 | ], |
||
394 | ]; |
||
395 | } |
||
396 | |||
397 | /** |
||
398 | * Return a unique hash for this meta bundle settings model. |
||
399 | * |
||
400 | * @return string |
||
401 | */ |
||
402 | public function getHash() { |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
403 | return spl_object_hash($this); |
||
404 | } |
||
405 | } |
||
406 |