Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
239 changes: 239 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,48 @@ A nice start to a collection of Magento 2 code snippets for Visual Studio Code!
</ul>
</details>

### Modules
<details>
<summary><a href="#mod-instructions">Instructions</a></summary>
<ul>
<li><a href="#module-xml">Module XML</a></li>
<li><a href="#registration-php">Registration</a></li>
</ul>
</details>

### DI
<details>
<summary><a href="#di-instructions">Instructions</a></summary>
<ul>
<li><a href="#di-scaffold">Scaffold</a></li>
<li><a href="#preference">Preference</a></li>
<li><a href="#type">Type</a></li>
<li><a href="#plugin">Plugin</a></li>
<li><a href="#virtual-type">Virtual Type</a></li>
</ul>
</details>

### Events
<details>
<summary><a href="#events-instructions">Instructions</a></summary>
<ul>
<li><a href="#events-scaffold">Scaffold</a></li>
<li><a href="#event">Event</a></li>
<li><a href="#observer">Observer</a></li>
</ul>
</details>

### Routes
<details>
<summary><a href="#routes-instructions">Instructions</a></summary>
<ul>
<li><a href="#routes-scaffold">Scaffold</a></li>
<li><a href="#routers">Routers</a></li>
<li><a href="#route">Route</a></li>
</ul>
</details>


# Layouts

## Instructions
Expand Down Expand Up @@ -345,3 +387,200 @@ display=""
```xml
remove=""
```


# Modules

## Module Instructions

### Module XML

**Trigger:** `m2.module`

**Output:**
```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/module.xsd">
<module name="" setup_version="0.1.0" />

</config>
```

### 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
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

</config>
```

### Preference

**Trigger:** `m2.di.pref`

**Output:**
```xml
<preference for="" type="" />
```

### Type

**Trigger:** `m2.di.type`

**Output:**
```xml
<type name="">

</type>
```

#### Type Arguments

**Trigger:** `m2.di.type.args`

**Output:**
```xml
<arguments>
<argument name="" xsi:type=""></argument>
</arguments>
```

#### Type Arguments Item

**Trigger:** `m2.di.type.args.item`

**Output:**
```xml
<item name="" xsi:type=""></item>
```

### Plugin

**Trigger:** `m2.di.plugin`

**Output:**
```xml
<plugin name=""
type=""
sortOrder=""/>
```

### Virtual Type

**Trigger:** `m2.di.virtualtype`

**Output:**
```xml
<virtualType name="" type="">

</virtualType>
```


# Events

## Events Instructions

### Events Scaffold

**Trigger:** `m2.events`

**Output:**
```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">

</config>
```


### Event

**Trigger:** `m2.events.event`

**Output:**
```xml
<event name="">

</event>
```


### Observer

**Trigger:** `m2.events.observer`

**Output:**
```xml
<observer name="" instance="" />
```


# Routes

## Routes Instructions

### Routes Scaffold

**Trigger:** `m2.routes`

**Output:**
```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">

</config>
```


### Routers

**Trigger:** `m2.routes.router`

**Output:**
```xml
<router id="">

</router>
```


### Route

**Trigger:** `m2.routes.route`

**Output:**
```xml
<route id="" frontName="">
<module name="" />
</route>
```



22 changes: 21 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
]
}
Expand Down
62 changes: 62 additions & 0 deletions snippets/di.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"DI Scaffold": {
"prefix": "m2.di",
"body": [
"<?xml version=\"1.0\"?>",
"<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ",
"\t\txsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/config.xsd\">",
"\t$0",
"</config>"
],
"description": "Magento 2 DI scaffold"
},
"DI Preference": {
"prefix": "m2.di.pref",
"body": [
"<preference for=\"${1:Fully Qualified Classname}\" type=\"${2:Fully Qualified Classname}\" />$0"
],
"description": "Magento 2 DI preference"
},
"DI Type": {
"prefix": "m2.di.type",
"body": [
"<type name=\"${1:Fully Qualified Classname}\">",
"\t$0",
"</type>"
],
"description": "Magento 2 DI type"
},
"DI Plugin": {
"prefix": "m2.di.plugin",
"body": [
"<plugin name=\"${1:plugin_name}\" ",
"\ttype=\"${2:Fully Qualified Classname}\"",
"\tsortOrder=\"${3}\"/>$0"
]
},
"DI Type Arguments": {
"prefix": "m2.di.args",
"body": [
"<arguments>",
"\t<argument name=\"${1:Constructor Argument}\" xsi:type=\"${2|array,boolean,number,null,object,string|}\">$3</argument>",
"</arguments>$0"
],
"description": "Magento 2 DI type arguments"
},
"DI Type Argument Item": {
"prefix": "m2.di.args.item",
"body": [
"<item name=\"${1}\" xsi:type=\"${2|array,boolean,number,null,object,string|}\">$3</item>$0"
],
"description": "Magento 2 DI type argument item"
},
"DI Virtual Type": {
"prefix": "m2.di.virtualtype",
"body": [
"<virtualType name=\"${1:Virtual Type Name}\" type=\"${2:Fully Qualified Classname}\">",
"\t$0",
"</virtualType>"
],
"description": "Magento 2 DI type"
}
}
30 changes: 30 additions & 0 deletions snippets/events.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"Events Scaffold": {
"prefix": "m2.events",
"body": [
"<?xml version=\"1.0\"?>",
"<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"",
"\t\txsi:noNamespaceSchemaLocation=\"urn:magento:framework:Event/etc/events.xsd\">",
"\t$0",
"</config>"
],
"description": "Magento 2 events scaffold"
},
"Event": {
"prefix": "m2.events.event",
"body": [
"<event name=\"${1:event_name}\">",
"\t$0",
"</event>"
],
"description": "Magento 2 event"
},
"Observer": {
"prefix": "m2.events.observer",
"body": [
"<observer name=\"${1:observer_name}\"",
"\tinstance=\"${2:Fully Qualified Classname}\" />"
],
"description": "Magento 2 event observer"
}
}
13 changes: 13 additions & 0 deletions snippets/module/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"Module": {
"prefix": "m2.module",
"body": [
"<?xml version=\"1.0\"?>",
"<config xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ",
"\t\txsi:noNamespaceSchemaLocation=\"urn:magento:framework:ObjectManager/etc/module.xsd\">",
"\t<module name=\"${1:Vendor_Module}\" setup_version=\"0.1.0\" />",
"</config>"
],
"description": "Magento 2 DI scaffold"
}
}
Loading