Skip to content

Commit 3892303

Browse files
author
Jerry Lopez
authored
Merge pull request #2 from lfolco/master
Added new snippets
2 parents c7922be + 8753b17 commit 3892303

File tree

8 files changed

+410
-1
lines changed

8 files changed

+410
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,48 @@ A nice start to a collection of Magento 2 code snippets for Visual Studio Code!
4747
</ul>
4848
</details>
4949

50+
### Modules
51+
<details>
52+
<summary><a href="#mod-instructions">Instructions</a></summary>
53+
<ul>
54+
<li><a href="#module-xml">Module XML</a></li>
55+
<li><a href="#registration-php">Registration</a></li>
56+
</ul>
57+
</details>
58+
59+
### DI
60+
<details>
61+
<summary><a href="#di-instructions">Instructions</a></summary>
62+
<ul>
63+
<li><a href="#di-scaffold">Scaffold</a></li>
64+
<li><a href="#preference">Preference</a></li>
65+
<li><a href="#type">Type</a></li>
66+
<li><a href="#plugin">Plugin</a></li>
67+
<li><a href="#virtual-type">Virtual Type</a></li>
68+
</ul>
69+
</details>
70+
71+
### Events
72+
<details>
73+
<summary><a href="#events-instructions">Instructions</a></summary>
74+
<ul>
75+
<li><a href="#events-scaffold">Scaffold</a></li>
76+
<li><a href="#event">Event</a></li>
77+
<li><a href="#observer">Observer</a></li>
78+
</ul>
79+
</details>
80+
81+
### Routes
82+
<details>
83+
<summary><a href="#routes-instructions">Instructions</a></summary>
84+
<ul>
85+
<li><a href="#routes-scaffold">Scaffold</a></li>
86+
<li><a href="#routers">Routers</a></li>
87+
<li><a href="#route">Route</a></li>
88+
</ul>
89+
</details>
90+
91+
5092
# Layouts
5193

5294
## Instructions
@@ -345,3 +387,200 @@ display=""
345387
```xml
346388
remove=""
347389
```
390+
391+
392+
# Modules
393+
394+
## Module Instructions
395+
396+
### Module XML
397+
398+
**Trigger:** `m2.module`
399+
400+
**Output:**
401+
```xml
402+
<?xml version="1.0"?>
403+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
404+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/module.xsd">
405+
<module name="" setup_version="0.1.0" />
406+
407+
</config>
408+
```
409+
410+
### Registration
411+
412+
**Trigger:** `m2.module.registration`
413+
414+
**Output:**
415+
```php
416+
\Magento\Framework\Component\ComponentRegistrar::register(
417+
\Magento\Framework\Component\ComponentRegistrar::MODULE,
418+
'',
419+
__DIR__
420+
);
421+
```
422+
423+
424+
# DI
425+
426+
## DI Instructions
427+
428+
### DI Scaffold
429+
430+
**Trigger:** `m2.di`
431+
432+
**Output:**
433+
```xml
434+
<?xml version="1.0"?>
435+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
436+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
437+
438+
</config>
439+
```
440+
441+
### Preference
442+
443+
**Trigger:** `m2.di.pref`
444+
445+
**Output:**
446+
```xml
447+
<preference for="" type="" />
448+
```
449+
450+
### Type
451+
452+
**Trigger:** `m2.di.type`
453+
454+
**Output:**
455+
```xml
456+
<type name="">
457+
458+
</type>
459+
```
460+
461+
#### Type Arguments
462+
463+
**Trigger:** `m2.di.type.args`
464+
465+
**Output:**
466+
```xml
467+
<arguments>
468+
<argument name="" xsi:type=""></argument>
469+
</arguments>
470+
```
471+
472+
#### Type Arguments Item
473+
474+
**Trigger:** `m2.di.type.args.item`
475+
476+
**Output:**
477+
```xml
478+
<item name="" xsi:type=""></item>
479+
```
480+
481+
### Plugin
482+
483+
**Trigger:** `m2.di.plugin`
484+
485+
**Output:**
486+
```xml
487+
<plugin name=""
488+
type=""
489+
sortOrder=""/>
490+
```
491+
492+
### Virtual Type
493+
494+
**Trigger:** `m2.di.virtualtype`
495+
496+
**Output:**
497+
```xml
498+
<virtualType name="" type="">
499+
500+
</virtualType>
501+
```
502+
503+
504+
# Events
505+
506+
## Events Instructions
507+
508+
### Events Scaffold
509+
510+
**Trigger:** `m2.events`
511+
512+
**Output:**
513+
```xml
514+
<?xml version="1.0"?>
515+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
516+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
517+
518+
</config>
519+
```
520+
521+
522+
### Event
523+
524+
**Trigger:** `m2.events.event`
525+
526+
**Output:**
527+
```xml
528+
<event name="">
529+
530+
</event>
531+
```
532+
533+
534+
### Observer
535+
536+
**Trigger:** `m2.events.observer`
537+
538+
**Output:**
539+
```xml
540+
<observer name="" instance="" />
541+
```
542+
543+
544+
# Routes
545+
546+
## Routes Instructions
547+
548+
### Routes Scaffold
549+
550+
**Trigger:** `m2.routes`
551+
552+
**Output:**
553+
```xml
554+
<?xml version="1.0"?>
555+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
556+
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
557+
558+
</config>
559+
```
560+
561+
562+
### Routers
563+
564+
**Trigger:** `m2.routes.router`
565+
566+
**Output:**
567+
```xml
568+
<router id="">
569+
570+
</router>
571+
```
572+
573+
574+
### Route
575+
576+
**Trigger:** `m2.routes.route`
577+
578+
**Output:**
579+
```xml
580+
<route id="" frontName="">
581+
<module name="" />
582+
</route>
583+
```
584+
585+
586+

package.json

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "magento2-snippets",
33
"displayName": "Magento 2 Snippets",
44
"description": "A collection of Magento 2 snippets",
5-
"version": "0.1.2",
5+
"version": "0.1.3",
66
"publisher": "jerrylopez",
77
"icon": "images/icon.png",
88
"license": "MIT",
@@ -53,6 +53,26 @@
5353
{
5454
"language": "xml",
5555
"path": "./snippets/layout/update.json"
56+
},
57+
{
58+
"language": "xml",
59+
"path": "./snippets/di.json"
60+
},
61+
{
62+
"language": "xml",
63+
"path": "./snippets/module/module.json"
64+
},
65+
{
66+
"language": "php",
67+
"path": "./snippets/module/registration.json"
68+
},
69+
{
70+
"language": "xml",
71+
"path": "./snippets/events.json"
72+
},
73+
{
74+
"language": "xml",
75+
"path": "./snippets/routes.json"
5676
}
5777
]
5878
}

snippets/di.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"DI Scaffold": {
3+
"prefix": "m2.di",
4+
"body": [
5+
"<?xml version=\"1.0\"?>",
6+
"<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ",
7+
"\t\txsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/config.xsd\">",
8+
"\t$0",
9+
"</config>"
10+
],
11+
"description": "Magento 2 DI scaffold"
12+
},
13+
"DI Preference": {
14+
"prefix": "m2.di.pref",
15+
"body": [
16+
"<preference for=\"${1:Fully Qualified Classname}\" type=\"${2:Fully Qualified Classname}\" />$0"
17+
],
18+
"description": "Magento 2 DI preference"
19+
},
20+
"DI Type": {
21+
"prefix": "m2.di.type",
22+
"body": [
23+
"<type name=\"${1:Fully Qualified Classname}\">",
24+
"\t$0",
25+
"</type>"
26+
],
27+
"description": "Magento 2 DI type"
28+
},
29+
"DI Plugin": {
30+
"prefix": "m2.di.plugin",
31+
"body": [
32+
"<plugin name=\"${1:plugin_name}\" ",
33+
"\ttype=\"${2:Fully Qualified Classname}\"",
34+
"\tsortOrder=\"${3}\"/>$0"
35+
]
36+
},
37+
"DI Type Arguments": {
38+
"prefix": "m2.di.args",
39+
"body": [
40+
"<arguments>",
41+
"\t<argument name=\"${1:Constructor Argument}\" xsi:type=\"${2|array,boolean,number,null,object,string|}\">$3</argument>",
42+
"</arguments>$0"
43+
],
44+
"description": "Magento 2 DI type arguments"
45+
},
46+
"DI Type Argument Item": {
47+
"prefix": "m2.di.args.item",
48+
"body": [
49+
"<item name=\"${1}\" xsi:type=\"${2|array,boolean,number,null,object,string|}\">$3</item>$0"
50+
],
51+
"description": "Magento 2 DI type argument item"
52+
},
53+
"DI Virtual Type": {
54+
"prefix": "m2.di.virtualtype",
55+
"body": [
56+
"<virtualType name=\"${1:Virtual Type Name}\" type=\"${2:Fully Qualified Classname}\">",
57+
"\t$0",
58+
"</virtualType>"
59+
],
60+
"description": "Magento 2 DI type"
61+
}
62+
}

snippets/events.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"Events Scaffold": {
3+
"prefix": "m2.events",
4+
"body": [
5+
"<?xml version=\"1.0\"?>",
6+
"<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"",
7+
"\t\txsi:noNamespaceSchemaLocation=\"urn:magento:framework:Event/etc/events.xsd\">",
8+
"\t$0",
9+
"</config>"
10+
],
11+
"description": "Magento 2 events scaffold"
12+
},
13+
"Event": {
14+
"prefix": "m2.events.event",
15+
"body": [
16+
"<event name=\"${1:event_name}\">",
17+
"\t$0",
18+
"</event>"
19+
],
20+
"description": "Magento 2 event"
21+
},
22+
"Observer": {
23+
"prefix": "m2.events.observer",
24+
"body": [
25+
"<observer name=\"${1:observer_name}\"",
26+
"\tinstance=\"${2:Fully Qualified Classname}\" />"
27+
],
28+
"description": "Magento 2 event observer"
29+
}
30+
}

snippets/module/module.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"Module": {
3+
"prefix": "m2.module",
4+
"body": [
5+
"<?xml version=\"1.0\"?>",
6+
"<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ",
7+
"\t\txsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/module.xsd\">",
8+
"\t<module name=\"${1:Vendor_Module}\" setup_version=\"0.1.0\" />",
9+
"</config>"
10+
],
11+
"description": "Magento 2 DI scaffold"
12+
}
13+
}

0 commit comments

Comments
 (0)