1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* CodeEditor for Craft CMS |
4
|
|
|
* |
5
|
|
|
* Provides a code editor field with Twig & Craft API autocomplete |
6
|
|
|
* |
7
|
|
|
* @link https://nystudio107.com |
|
|
|
|
8
|
|
|
* @copyright Copyright (c) 2022 nystudio107 |
|
|
|
|
9
|
|
|
*/ |
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace nystudio107\codeeditor\models; |
12
|
|
|
|
13
|
|
|
use craft\base\Model; |
14
|
|
|
use craft\validators\ArrayValidator; |
15
|
|
|
use nystudio107\codeeditor\autocompletes\CraftApiAutocomplete; |
16
|
|
|
use nystudio107\codeeditor\autocompletes\SectionShorthandFieldsAutocomplete; |
17
|
|
|
use nystudio107\codeeditor\autocompletes\TwigLanguageAutocomplete; |
18
|
|
|
|
19
|
|
|
/** |
|
|
|
|
20
|
|
|
* @author nystudio107 |
|
|
|
|
21
|
|
|
* @package CodeEditor |
|
|
|
|
22
|
|
|
* @since 1.0.0 |
|
|
|
|
23
|
|
|
*/ |
|
|
|
|
24
|
|
|
class Settings extends Model |
25
|
|
|
{ |
26
|
|
|
// Public Properties |
27
|
|
|
// ========================================================================= |
28
|
|
|
|
29
|
|
|
/** |
|
|
|
|
30
|
|
|
* @var bool Whether to allow anonymous access be allowed to the codeeditor/autocomplete/index endpoint |
31
|
|
|
*/ |
32
|
|
|
public $allowFrontendAccess = false; |
33
|
|
|
|
34
|
|
|
/** |
|
|
|
|
35
|
|
|
* @var bool Whether to allow frontend templates access to the `codeeditor/codeEditor.twig` Twig template |
36
|
|
|
*/ |
37
|
|
|
public $allowTemplateAccess = true; |
38
|
|
|
|
39
|
|
|
/** |
|
|
|
|
40
|
|
|
* @var string[] The default autocompletes to use for the default `CodeEditor` field type |
41
|
|
|
*/ |
42
|
|
|
public $defaultCodeEditorAutocompletes = [ |
43
|
|
|
CraftApiAutocomplete::class, |
44
|
|
|
TwigLanguageAutocomplete::class, |
45
|
|
|
SectionShorthandFieldsAutocomplete::class, |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
// Public Methods |
49
|
|
|
// ========================================================================= |
50
|
|
|
|
51
|
|
|
/** |
|
|
|
|
52
|
|
|
* @inheritdoc |
53
|
|
|
*/ |
|
|
|
|
54
|
|
|
public function defineRules(): array |
55
|
|
|
{ |
56
|
|
|
return [ |
57
|
|
|
[['allowFrontendAccess', 'allowTemplateAccess'], 'boolean'], |
58
|
|
|
['defaultCodeFieldAutocompletes', ArrayValidator::class], |
59
|
|
|
]; |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|