diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..496ee2c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store \ No newline at end of file diff --git a/README.md b/README.md index 2be8cf4..cf0e31b 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,48 @@ A nice start to a collection of Magento 2 code snippets for Visual Studio Code! +### Modules +
+ Instructions + +
+ +### DI +
+ Instructions + +
+ +### Events +
+ Instructions + +
+ +### Routes +
+ Instructions + +
+ + # Layouts ## Instructions @@ -345,3 +387,200 @@ display="" ```xml remove="" ``` + + +# Modules + +## Module Instructions + +### Module XML + +**Trigger:** `m2.module` + +**Output:** +```xml + + + + + +``` + +### Registration + +**Trigger:** `m2.module.registration` + +**Output:** +```php +\Magento\Framework\Component\ComponentRegistrar::register( + \Magento\Framework\Component\ComponentRegistrar::MODULE, + '', + __DIR__ +); +``` + + +# DI + +## DI Instructions + +### DI Scaffold + +**Trigger:** `m2.di` + +**Output:** +```xml + + + + +``` + +### Preference + +**Trigger:** `m2.di.pref` + +**Output:** +```xml + +``` + +### Type + +**Trigger:** `m2.di.type` + +**Output:** +```xml + + + +``` + +#### Type Arguments + +**Trigger:** `m2.di.type.args` + +**Output:** +```xml + + + +``` + +#### Type Arguments Item + +**Trigger:** `m2.di.type.args.item` + +**Output:** +```xml + +``` + +### Plugin + +**Trigger:** `m2.di.plugin` + +**Output:** +```xml + +``` + +### Virtual Type + +**Trigger:** `m2.di.virtualtype` + +**Output:** +```xml + + + +``` + + +# Events + +## Events Instructions + +### Events Scaffold + +**Trigger:** `m2.events` + +**Output:** +```xml + + + + +``` + + +### Event + +**Trigger:** `m2.events.event` + +**Output:** +```xml + + + +``` + + +### Observer + +**Trigger:** `m2.events.observer` + +**Output:** +```xml + +``` + + +# Routes + +## Routes Instructions + +### Routes Scaffold + +**Trigger:** `m2.routes` + +**Output:** +```xml + + + + +``` + + +### Routers + +**Trigger:** `m2.routes.router` + +**Output:** +```xml + + + +``` + + +### Route + +**Trigger:** `m2.routes.route` + +**Output:** +```xml + + + +``` + + + diff --git a/package.json b/package.json index f660490..71b2e58 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "magento2-snippets", "displayName": "Magento 2 Snippets", "description": "A collection of Magento 2 snippets", - "version": "0.1.2", + "version": "0.1.3", "publisher": "jerrylopez", "icon": "images/icon.png", "license": "MIT", @@ -53,6 +53,26 @@ { "language": "xml", "path": "./snippets/layout/update.json" + }, + { + "language": "xml", + "path": "./snippets/di.json" + }, + { + "language": "xml", + "path": "./snippets/module/module.json" + }, + { + "language": "php", + "path": "./snippets/module/registration.json" + }, + { + "language": "xml", + "path": "./snippets/events.json" + }, + { + "language": "xml", + "path": "./snippets/routes.json" } ] } diff --git a/snippets/di.json b/snippets/di.json new file mode 100644 index 0000000..10ad77f --- /dev/null +++ b/snippets/di.json @@ -0,0 +1,62 @@ +{ + "DI Scaffold": { + "prefix": "m2.di", + "body": [ + "", + "", + "\t$0", + "" + ], + "description": "Magento 2 DI scaffold" + }, + "DI Preference": { + "prefix": "m2.di.pref", + "body": [ + "$0" + ], + "description": "Magento 2 DI preference" + }, + "DI Type": { + "prefix": "m2.di.type", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 DI type" + }, + "DI Plugin": { + "prefix": "m2.di.plugin", + "body": [ + "$0" + ] + }, + "DI Type Arguments": { + "prefix": "m2.di.args", + "body": [ + "", + "\t$3", + "$0" + ], + "description": "Magento 2 DI type arguments" + }, + "DI Type Argument Item": { + "prefix": "m2.di.args.item", + "body": [ + "$3$0" + ], + "description": "Magento 2 DI type argument item" + }, + "DI Virtual Type": { + "prefix": "m2.di.virtualtype", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 DI type" + } +} diff --git a/snippets/events.json b/snippets/events.json new file mode 100644 index 0000000..e32f2f6 --- /dev/null +++ b/snippets/events.json @@ -0,0 +1,30 @@ +{ + "Events Scaffold": { + "prefix": "m2.events", + "body": [ + "", + "", + "\t$0", + "" + ], + "description": "Magento 2 events scaffold" + }, + "Event": { + "prefix": "m2.events.event", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 event" + }, + "Observer": { + "prefix": "m2.events.observer", + "body": [ + "" + ], + "description": "Magento 2 event observer" + } +} \ No newline at end of file diff --git a/snippets/module/module.json b/snippets/module/module.json new file mode 100644 index 0000000..e32c7a0 --- /dev/null +++ b/snippets/module/module.json @@ -0,0 +1,13 @@ +{ + "Module": { + "prefix": "m2.module", + "body": [ + "", + "", + "\t", + "" + ], + "description": "Magento 2 DI scaffold" + } +} \ No newline at end of file diff --git a/snippets/module/registration.json b/snippets/module/registration.json new file mode 100644 index 0000000..1d937a4 --- /dev/null +++ b/snippets/module/registration.json @@ -0,0 +1,13 @@ +{ + "Registration": { + "prefix": "m2.module.registration", + "body": [ + "\\Magento\\Framework\\Component\\ComponentRegistrar::register(", + "\t\\Magento\\Framework\\Component\\ComponentRegistrar::MODULE,", + "\t'${1:Vendor_Module}',", + "\t__DIR__", + ");" + ], + "description": "Magento 2 registration file" + } +} \ No newline at end of file diff --git a/snippets/routes.json b/snippets/routes.json new file mode 100644 index 0000000..1833475 --- /dev/null +++ b/snippets/routes.json @@ -0,0 +1,31 @@ +{ + "Routes Scaffold": { + "prefix": "m2.routes", + "body": [ + "", + "", + "\t$0", + "" + ], + "description": "Magento 2 routes scaffold" + }, + "Router": { + "prefix": "m2.routes.router", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 event" + }, + "Route": { + "prefix": "m2.routes.route", + "body": [ + "", + "\t", + "" + ], + "description": "Magento 2 event observer" + } +} \ No newline at end of file