From 32c6e960a277fcaba68d4d45aaad9072784fce93 Mon Sep 17 00:00:00 2001 From: Laura Folco Date: Wed, 8 Nov 2017 20:03:16 -0500 Subject: [PATCH 1/6] added snippets for DI --- snippets/di/preference.json | 9 +++++++++ snippets/di/scaffold.json | 12 ++++++++++++ snippets/di/type.json | 27 +++++++++++++++++++++++++++ snippets/di/virtualtype.json | 11 +++++++++++ 4 files changed, 59 insertions(+) create mode 100644 snippets/di/preference.json create mode 100644 snippets/di/scaffold.json create mode 100644 snippets/di/type.json create mode 100644 snippets/di/virtualtype.json diff --git a/snippets/di/preference.json b/snippets/di/preference.json new file mode 100644 index 0000000..4d8d4a4 --- /dev/null +++ b/snippets/di/preference.json @@ -0,0 +1,9 @@ +{ + "DI Preference": { + "prefix": "m2.di.pref", + "body": [ + "$0", + ], + "description": "Magento 2 DI preference" + } +} diff --git a/snippets/di/scaffold.json b/snippets/di/scaffold.json new file mode 100644 index 0000000..4b319ef --- /dev/null +++ b/snippets/di/scaffold.json @@ -0,0 +1,12 @@ +{ + "DI Scaffold": { + "prefix": "m2.di", + "body": [ + "", + "", + "\t$0", + "" + ], + "description": "Magento 2 DI scaffold" + } +} diff --git a/snippets/di/type.json b/snippets/di/type.json new file mode 100644 index 0000000..a3d2933 --- /dev/null +++ b/snippets/di/type.json @@ -0,0 +1,27 @@ +{ + "DI Type": { + "prefix": "m2.di.type", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 DI type" + }, + "DI Type Arguments": { + "prefix": "m2.di.type.args", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 DI type arguments" + }, + "DI Type Argument Item": { + "prefix": "m2.di.type.args.item", + "body": [ + "$0" + ], + "description": "Magento 2 DI type argument item" + } +} \ No newline at end of file diff --git a/snippets/di/virtualtype.json b/snippets/di/virtualtype.json new file mode 100644 index 0000000..fdd2191 --- /dev/null +++ b/snippets/di/virtualtype.json @@ -0,0 +1,11 @@ +{ + "DI Virtual Type": { + "prefix": "m2.di.virtualtype", + "body": [ + "", + "\t$0", + "" + ], + "description": "Magento 2 DI type" + } +} From a582e626d9a4db878dfdc182575b2fac6b71bb37 Mon Sep 17 00:00:00 2001 From: Laura Folco Date: Fri, 10 Nov 2017 12:15:04 -0500 Subject: [PATCH 2/6] added routes, events, module --- package.json | 32 +++++++++++++++++++++++++++++++ snippets/di/scaffold.json | 5 +++-- snippets/events.json | 30 +++++++++++++++++++++++++++++ snippets/module/module.json | 13 +++++++++++++ snippets/module/registration.json | 13 +++++++++++++ snippets/routes.json | 31 ++++++++++++++++++++++++++++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 snippets/events.json create mode 100644 snippets/module/module.json create mode 100644 snippets/module/registration.json create mode 100644 snippets/routes.json diff --git a/package.json b/package.json index f660490..e565dbf 100644 --- a/package.json +++ b/package.json @@ -53,6 +53,38 @@ { "language": "xml", "path": "./snippets/layout/update.json" + }, + { + "language": "xml", + "path": "./snippets/di/preference.json" + }, + { + "language": "xml", + "path": "./snippets/di/scaffold.json" + }, + { + "language": "xml", + "path": "./snippets/di/type.json" + }, + { + "language": "xml", + "path": "./snippets/di/virtualtype.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/scaffold.json b/snippets/di/scaffold.json index 4b319ef..5a12949 100644 --- a/snippets/di/scaffold.json +++ b/snippets/di/scaffold.json @@ -3,9 +3,10 @@ "prefix": "m2.di", "body": [ "", - "", + "", "\t$0", - "" + "" ], "description": "Magento 2 DI scaffold" } 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 From 731462320d4853a93f4e820f48b7240456e47164 Mon Sep 17 00:00:00 2001 From: Laura Folco Date: Fri, 10 Nov 2017 12:20:59 -0500 Subject: [PATCH 3/6] added events, di, modules --- README.md | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) diff --git a/README.md b/README.md index 2be8cf4..bb4c114 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,47 @@ 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 +386,189 @@ 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 + +``` + +### 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 + + + +``` + + + From e2d698d2bcd87c064cdf4fbf04bc253ff9a0e889 Mon Sep 17 00:00:00 2001 From: lfolco Date: Sun, 12 Nov 2017 15:50:03 -0500 Subject: [PATCH 4/6] refactored DI into one file --- package.json | 14 +------- snippets/di.json | 62 ++++++++++++++++++++++++++++++++++++ snippets/di/preference.json | 9 ------ snippets/di/scaffold.json | 13 -------- snippets/di/type.json | 27 ---------------- snippets/di/virtualtype.json | 11 ------- 6 files changed, 63 insertions(+), 73 deletions(-) create mode 100644 snippets/di.json delete mode 100644 snippets/di/preference.json delete mode 100644 snippets/di/scaffold.json delete mode 100644 snippets/di/type.json delete mode 100644 snippets/di/virtualtype.json diff --git a/package.json b/package.json index e565dbf..7eee140 100644 --- a/package.json +++ b/package.json @@ -56,19 +56,7 @@ }, { "language": "xml", - "path": "./snippets/di/preference.json" - }, - { - "language": "xml", - "path": "./snippets/di/scaffold.json" - }, - { - "language": "xml", - "path": "./snippets/di/type.json" - }, - { - "language": "xml", - "path": "./snippets/di/virtualtype.json" + "path": "./snippets/di.json" }, { "language": "xml", 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/di/preference.json b/snippets/di/preference.json deleted file mode 100644 index 4d8d4a4..0000000 --- a/snippets/di/preference.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "DI Preference": { - "prefix": "m2.di.pref", - "body": [ - "$0", - ], - "description": "Magento 2 DI preference" - } -} diff --git a/snippets/di/scaffold.json b/snippets/di/scaffold.json deleted file mode 100644 index 5a12949..0000000 --- a/snippets/di/scaffold.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "DI Scaffold": { - "prefix": "m2.di", - "body": [ - "", - "", - "\t$0", - "" - ], - "description": "Magento 2 DI scaffold" - } -} diff --git a/snippets/di/type.json b/snippets/di/type.json deleted file mode 100644 index a3d2933..0000000 --- a/snippets/di/type.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "DI Type": { - "prefix": "m2.di.type", - "body": [ - "", - "\t$0", - "" - ], - "description": "Magento 2 DI type" - }, - "DI Type Arguments": { - "prefix": "m2.di.type.args", - "body": [ - "", - "\t$0", - "" - ], - "description": "Magento 2 DI type arguments" - }, - "DI Type Argument Item": { - "prefix": "m2.di.type.args.item", - "body": [ - "$0" - ], - "description": "Magento 2 DI type argument item" - } -} \ No newline at end of file diff --git a/snippets/di/virtualtype.json b/snippets/di/virtualtype.json deleted file mode 100644 index fdd2191..0000000 --- a/snippets/di/virtualtype.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "DI Virtual Type": { - "prefix": "m2.di.virtualtype", - "body": [ - "", - "\t$0", - "" - ], - "description": "Magento 2 DI type" - } -} From 04574a20ae2fb5e075242771dcf24288b0b80666 Mon Sep 17 00:00:00 2001 From: lfolco Date: Sun, 12 Nov 2017 15:51:57 -0500 Subject: [PATCH 5/6] added plugin --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index bb4c114..cf0e31b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,7 @@ A nice start to a collection of Magento 2 code snippets for Visual Studio Code!
  • Scaffold
  • Preference
  • Type
  • +
  • Plugin
  • Virtual Type
  • @@ -477,6 +478,17 @@ remove="" ``` +### Plugin + +**Trigger:** `m2.di.plugin` + +**Output:** +```xml + +``` + ### Virtual Type **Trigger:** `m2.di.virtualtype` From 8753b17bb09ef15a3233c07f2a1815bd6cf57d1b Mon Sep 17 00:00:00 2001 From: lfolco Date: Sun, 12 Nov 2017 15:53:36 -0500 Subject: [PATCH 6/6] bump version to 0.1.3; added .gitignore --- .gitignore | 1 + package.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .gitignore 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/package.json b/package.json index 7eee140..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",