nystudio107 /
craft-templatecomments
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Template Comments plugin for Craft CMS |
||
| 4 | * |
||
| 5 | * Adds a HTML comment to demarcate each Twig template that is included or extended. |
||
| 6 | * |
||
| 7 | * @link https://nystudio107.com/ |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 8 | * @copyright Copyright (c) nystudio107 |
||
|
0 ignored issues
–
show
|
|||
| 9 | */ |
||
|
0 ignored issues
–
show
|
|||
| 10 | |||
| 11 | namespace nystudio107\templatecomments\models; |
||
| 12 | |||
| 13 | use craft\base\Model; |
||
| 14 | use craft\validators\ArrayValidator; |
||
| 15 | |||
| 16 | /** |
||
|
0 ignored issues
–
show
|
|||
| 17 | * @author nystudio107 |
||
|
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
|
|||
| 18 | * @package TemplateComments |
||
|
0 ignored issues
–
show
|
|||
| 19 | * @since 1.0.0 |
||
|
0 ignored issues
–
show
|
|||
| 20 | */ |
||
|
0 ignored issues
–
show
|
|||
| 21 | class Settings extends Model |
||
| 22 | { |
||
| 23 | // Public Properties |
||
| 24 | // ========================================================================= |
||
| 25 | |||
| 26 | /** |
||
|
0 ignored issues
–
show
|
|||
| 27 | * @var bool Whether comments should be generated for site templates |
||
| 28 | */ |
||
| 29 | public bool $siteTemplateComments = true; |
||
| 30 | |||
| 31 | /** |
||
|
0 ignored issues
–
show
|
|||
| 32 | * @var bool Whether comments should be generated for Control Panel templates |
||
| 33 | */ |
||
| 34 | public bool $cpTemplateComments = false; |
||
| 35 | |||
| 36 | /** |
||
|
0 ignored issues
–
show
|
|||
| 37 | * @var bool Whether to generate comments only when `devMode` is on |
||
| 38 | */ |
||
| 39 | public bool $onlyCommentsInDevMode = true; |
||
| 40 | |||
| 41 | /** |
||
|
0 ignored issues
–
show
|
|||
| 42 | * @var array Don't add comments to template blocks that contain these strings (case-insensitive) |
||
| 43 | */ |
||
| 44 | public array $excludeBlocksThatContain = [ |
||
| 45 | 'css', |
||
| 46 | 'js', |
||
| 47 | 'javascript', |
||
| 48 | ]; |
||
| 49 | |||
| 50 | /** |
||
|
0 ignored issues
–
show
|
|||
| 51 | * @var bool Whether or not to show comments for templates that are include'd |
||
| 52 | */ |
||
| 53 | public bool $templateCommentsEnabled = true; |
||
| 54 | |||
| 55 | /** |
||
|
0 ignored issues
–
show
|
|||
| 56 | * @var bool Whether or not to show comments for `{% block %}`s |
||
| 57 | */ |
||
| 58 | public bool $blockCommentsEnabled = true; |
||
| 59 | |||
| 60 | /** |
||
|
0 ignored issues
–
show
|
|||
| 61 | * @var array Template file suffixes that Template Comments should be enabled for |
||
| 62 | */ |
||
| 63 | public array $allowedTemplateSuffixes = [ |
||
| 64 | '', |
||
| 65 | 'twig', |
||
| 66 | 'htm', |
||
| 67 | 'html', |
||
| 68 | ]; |
||
| 69 | |||
| 70 | // Public Methods |
||
| 71 | // ========================================================================= |
||
| 72 | /** |
||
|
0 ignored issues
–
show
|
|||
| 73 | * @inerhitdoc |
||
| 74 | */ |
||
|
0 ignored issues
–
show
|
|||
| 75 | public function rules(): array |
||
| 76 | { |
||
| 77 | return [ |
||
| 78 | [ |
||
| 79 | [ |
||
| 80 | 'siteTemplateComments', |
||
| 81 | 'cpTemplateComments', |
||
| 82 | 'onlyCommentsInDevMode', |
||
| 83 | 'templateCommentsEnabled', |
||
| 84 | 'blockCommentsEnabled', |
||
| 85 | ], |
||
| 86 | 'boolean', |
||
| 87 | ], |
||
| 88 | [ |
||
| 89 | [ |
||
| 90 | 'excludeBlocksThatContain', |
||
| 91 | 'allowedTemplateSuffixes', |
||
| 92 | ], |
||
| 93 | ArrayValidator::class, |
||
| 94 | ], |
||
| 95 | ]; |
||
| 96 | } |
||
| 97 | } |
||
| 98 |