nystudio107 /
craft-code-editor
| 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 |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 8 | * @copyright Copyright (c) 2022 nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 9 | */ |
||
|
0 ignored issues
–
show
|
|||
| 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 | /** |
||
|
0 ignored issues
–
show
|
|||
| 20 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 21 | * @package CodeEditor |
||
|
0 ignored issues
–
show
|
|||
| 22 | * @since 1.0.0 |
||
|
0 ignored issues
–
show
|
|||
| 23 | */ |
||
|
0 ignored issues
–
show
|
|||
| 24 | class Settings extends Model |
||
| 25 | { |
||
| 26 | // Public Properties |
||
| 27 | // ========================================================================= |
||
| 28 | |||
| 29 | /** |
||
|
0 ignored issues
–
show
|
|||
| 30 | * @var bool Whether to allow anonymous access be allowed to the codeeditor/autocomplete/index endpoint |
||
| 31 | */ |
||
| 32 | public $allowFrontendAccess = false; |
||
| 33 | |||
| 34 | /** |
||
|
0 ignored issues
–
show
|
|||
| 35 | * @var bool Whether to allow frontend templates access to the `codeeditor/codeEditor.twig` Twig template |
||
| 36 | */ |
||
| 37 | public $allowTemplateAccess = true; |
||
| 38 | |||
| 39 | /** |
||
|
0 ignored issues
–
show
|
|||
| 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 | /** |
||
|
0 ignored issues
–
show
|
|||
| 52 | * @inheritdoc |
||
| 53 | */ |
||
|
0 ignored issues
–
show
|
|||
| 54 | public function defineRules(): array |
||
| 55 | { |
||
| 56 | return [ |
||
| 57 | [['allowFrontendAccess', 'allowTemplateAccess'], 'boolean'], |
||
| 58 | ['defaultCodeFieldAutocompletes', ArrayValidator::class], |
||
| 59 | ]; |
||
| 60 | } |
||
| 61 | } |
||
| 62 |