Last active
November 18, 2021 22:44
-
-
Save davejtoews/f48f6a576f6b409fedb419521422c17e to your computer and use it in GitHub Desktop.
SS4 Code Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"DataObject": { | |
"scope": "html", | |
"prefix": "SSDataObject", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use SilverStripe\\ORM\\DataObject;", | |
"", | |
"class ${2:ClassName} extends DataObject", | |
"{", | |
" private static \\$table_name = '${2:TableName}';", | |
"}", | |
"" | |
], | |
"description": "Template for new DataObject" | |
}, | |
"Page": { | |
"scope": "html", | |
"prefix": "SSPage", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use Page;", | |
"", | |
"class ${2:ClassName}Page extends Page", | |
"{", | |
" private static \\$table_name = '${2:TableName}Page';", | |
" private static \\$singular_name = '${3:Singular Name}';", | |
" private static \\$plural_name = '${4:Plural Name}';", | |
" private static \\$description = '${5}';", | |
" // https://silverstripe.github.io/silverstripe-pattern-lib/?selectedKind=Admin%2FIcons&selectedStory=Icon%20reference&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel", | |
" private static \\$icon_class = 'font-icon-${6:icon}';", | |
"}", | |
"" | |
], | |
"description": "Template for new Page" | |
}, | |
"Elemental": { | |
"scope": "html", | |
"prefix": "SSElement", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use DNADesign\\Elemental\\Models\\BaseElement;", | |
"", | |
"class ${2:ClassName}Element extends BaseElement", | |
"{", | |
" private static \\$table_name = '${2:TableName}Element';", | |
" private static \\$singular_name = '${3:Singular Name}';", | |
" private static \\$plural_name = '${4:Plural Name}';", | |
" // https://silverstripe.github.io/silverstripe-pattern-lib/?selectedKind=Admin%2FIcons&selectedStory=Icon%20reference&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel | |
" private static \\$icon = 'font-icon-${5:icon}';", | |
"", | |
" public function getType()", | |
" {", | |
" return '${3:Name}';", | |
" }", | |
"}", | |
"" | |
], | |
"description": "Template for new Element" | |
}, | |
"ModelAdmin": { | |
"scope": "html", | |
"prefix": "SSModelAdmin", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use SilverStripe\\Admin\\ModelAdmin;", | |
"", | |
"class ${2:ClassName}Admin extends ModelAdmin", | |
"{", | |
" private static \\$managed_models = [", | |
" ${3:Model}::class", | |
" ];", | |
"", | |
" private static \\$url_segment = '${4:path}';", | |
" private static \\$menu_title = '${5:Title}';", | |
" // https://silverstripe.github.io/silverstripe-pattern-lib/?selectedKind=Admin%2FIcons&selectedStory=Icon%20reference&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel", | |
" private static \\$menu_icon_class = 'font-icon-${6:icon}';", | |
"}", | |
"" | |
], | |
"description": "Template for new Model Admin" | |
}, | |
"Extension": { | |
"scope": "html", | |
"prefix": "SSExtension", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use SilverStripe\\Core\\Extension;", | |
"", | |
"class ${2:ClassName}Extension extends Extension", | |
"{", | |
" ${3}", | |
"}", | |
"" | |
], | |
"description": "Template for new Extension" | |
}, | |
"DataExtension": { | |
"scope": "html", | |
"prefix": "SSDataExtension", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use SilverStripe\\ORM\\DataExtension;", | |
"", | |
"class ${2:ClassName}Extension extends DataExtension", | |
"{", | |
" ${3}", | |
"}", | |
"" | |
], | |
"description": "Template for new DataExtension" | |
}, | |
"Controller": { | |
"scope": "html", | |
"prefix": "SSController", | |
"body": [ | |
"<?php", | |
"", | |
"namespace ${1:Namespace};", | |
"", | |
"use PageController;", | |
"", | |
"class ${2:ClassName}Controller extends PageController", | |
"{", | |
" ${3}", | |
"}", | |
"" | |
], | |
"description": "Template for new Controller" | |
} | |
} |
This is scoped to html because the php scope only lives within <?php
tags. To use these snippets, create a new file with the extension .php
. An empty file w/o the <?php
tag will be scoped to html.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code Snippets for SilverStripe Data Models in VS Code.