Skip to content

Commit

Permalink
Merge pull request #9 from leonhelmus/phpstorm/feature/liveTemplates
Browse files Browse the repository at this point in the history
Added live template files/ template files
  • Loading branch information
ksangers authored Aug 22, 2019
2 parents 6426b78 + 94704a1 commit 27afeca
Show file tree
Hide file tree
Showing 59 changed files with 979 additions and 154 deletions.
121 changes: 121 additions & 0 deletions COMMANDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# coding-standard-phpstorm

These commando's can be used in xml, php and phtml files.

## M2 XML
All xml templates make use of the includes "M2 XML File Header.xml".
All xml files also have appropriated xsd paths.

Available templates:
* M2 db schema xml:
* M2 di xml:
* M2 extension attributes xml:
* M2 layout xml:
* M2 module xml:

## M2 PHP Classes
All php files are PHP 7.1 or higher. These files have strict_types=1 on top of the templates and
make use of includes "M2 PHP File Header.php".

Make use of `new > file > PHP Class` and select a different template all PHP templates start with M2.
If the one mentioned below is not present go to `file > settings > Editor -> File and Code Templates` and enable the template you're searching for.
This way Namespaces and vendor will be automatically filled in.

Available templates:
* **M2 class**: Default M2 php class.
* **M2 class - Block**: PHP class that extends Template class.
* **M2 class - Helper**: PHP class that extends AbstractHelper
* **M2 class - Observer**: PHP class that implements ObserverInterface
* **M2 class - ViewModel**: PHP class that implements ArgumentInterface

## M2 ACL
Available templates:
* **M2 Acl XML**: Create an acl template that already has path to backend menu and backend config (system.xml)

Available commands:
* **m2aclresource** -> Create a resource tag, available params
* Vendor: vendor name
* namespace: name of module
* resourceId: acl id
* title: acl title
* order: sort order

## M2 Config
Available templates:
* **M2 Config XML**: Create an config with default structure.

Available commands:
* None

## M2 DB Schema
Available templates:
* **M2 Db schema XML**: Create an db schema with default structure.

Available commands:
* **m2dbtable**: Create an table.
* **m2dbcolumnvarchar**: Create an column as a varchar.
* **m2dbcolumnint**: Create an column as a int.
* **m2dbcolumndecimal**: Create an column decimal.
* **m2dbforeign**: Create an foreign key index.
* **m2dbcolumncreate**: Create an create created_at column.
* **m2dbindex**: Create an index.
* **m2dbcolumnupdate**: Create an updated_at column.

## M2 DI
Available templates:
* **M2 DI**: Create an DI file.

Available commands:
* **m2diplugin**: Create an plugin tyoe.
* **m2divirtual**: Create an virtual type
* **m2dipreference**: Create an preference(rewrite)

## M2 Extension Attribute
Available templates:
* **M2 Extension Attributes XML**: Create an extension attribute file with default structure.

## M2 Layout
Available templates:
* **M2 Layout XML**: Create an layout XML with default structure

## M2 Module
Available templates:
* **M2 Module XML**: Create an module XML file that has default structure

Available commands:
* **m2mod**: Create an module tag
* **m2modsequence**: Create an sequence tag

## M2 Registration
Available templates:
* **M2 Module XML**: Create an registration file with the method to register a m2 module

Available commands:
* **m2reg**: Create registration file

## M2 Sales
Available templates:
* **M2 Sales XML**: Create an sales xml file for registrating new totals.

Available commands:
* None

## M2 System / System Include
Available templates:
* **M2 System XML**: Create an system.xml with default structure.
* **M2 System Include XML**: Create an system include that can be included in a system.xml with default structure.

Available commands:
* **m2syssection**: Create an section tag.
* **m2sysinclude**: Create an include tag.
* **m2sysgroup**: Create an group tag.
* **m2sysfieldcmspage**: Create a dropdown field with all cms pages.
* **m2sysfieldyesno**: Create a dropdown with yes and no.
* **m2sysfieldpagelayout**: Create a dropdown with all page layouts.
* **m2sysfieldenabledisable**: Create a dropdown with enable/disable.
* **m2sysfieldpassword**: Create an obscure password field.
* **m2sysfieldtext**: Create a text field.
* **m2sysfieldtextarea**: Create a textarea field.
* **m2sysfieldpricetype**: Create a dropdown with all price types.
* **m2sysfieldproducttax**: Create a dropdown with all product taxes.
* **m2sysfieldcountry**: Create a dropdown with all countries.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,39 @@ composer require mediact/coding-standard-phpstorm
## Configuration
Use PHPStorm's `file > settings > language > PHP` menu to point to the installed binaries for PHPMD and PHPCS.

## Live Templates
You now get live templates that can be be found in `file > settings > Editor -> Live Templates` .
These can be enabled and disabled for if you want to use them or not.
At this moment there have been live templates created for:
* ACL
* DB Schema
* DI
* Module
* Phtml (WIP)
* Registration
* System

Check out [this link](COMMANDS.md) to see more info

## Templates
You now get live templates that can be be found in `file > settings > Editor -> File and Code Templates` .
These can be enabled and disabled for if you want to use them or not.
At this moment there have been templates created for:
* ACL
* Class
* Class - Block
* Class - Helper
* Class - Observer
* Class - ViewModel
* Config
* DB Schema
* DI
* Extension Attributes
* Layout
* Module
* Registration
* Sales
* System
* System Include

Check out [this link](COMMANDS.md) to see all commando's that can be used.
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
"email": "[email protected]"
}
],
"version": "1.7.0",
"require": {
"php": "^5.4.0 || ^7.0",
"php": "^5.4 || ^7.1",
"composer-plugin-api": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5",
"composer/composer": "^1.3",
"mediact/testing-suite": "@stable",
"kint-php/kint": "@stable",
"mediact/testing-suite": "^1.20",
"mikey179/vfsstream": "^1.6"
},
"autoload": {
Expand All @@ -30,10 +32,7 @@
}
},
"extra": {
"class": "Mediact\\CodingStandard\\PhpStorm\\Plugin",
"grumphp": {
"config-default-path": "vendor/mediact/testing-suite/config/default/grumphp.yml"
}
"class": "Mediact\\CodingStandard\\PhpStorm\\Plugin"
},
"archive": {
"exclude": [
Expand All @@ -43,7 +42,11 @@
"/phpunit.xml",
"/phpmd.xml",
"/phpstan.neon",
"/phpcs.xml"
"/phpcs.xml",
"/grumphp.yml"
]
},
"config": {
"sort-packages": true
}
}
18 changes: 18 additions & 0 deletions files/fileTemplates/M2 Acl XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">

</resource>
<resource id="Magento_Backend::stores">
<resource id="Magento_Backend::stores_settings">
<resource id="Magento_Config::config">
#[[$END$]]#
</resource>
</resource>
</resource>
</resources>
</acl>
</config>
13 changes: 13 additions & 0 deletions files/fileTemplates/M2 Class - Block.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
#parse("M2 PHP File Header")

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

use Magento\Framework\View\Element\Template;

class ${NAME} extends Template
{
#[[$END$]]#
}
13 changes: 13 additions & 0 deletions files/fileTemplates/M2 Class - Helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
#parse("M2 PHP File Header")

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

use Magento\Framework\App\Helper\AbstractHelper;

class ${NAME} extends AbstractHelper
{
#[[$END$]]#
}
13 changes: 13 additions & 0 deletions files/fileTemplates/M2 Class - Observer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
#parse("M2 PHP File Header")

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

use Magento\Framework\Event\ObserverInterface;

class ${NAME} implements ObserverInterface
{
#[[$END$]]#
}
13 changes: 13 additions & 0 deletions files/fileTemplates/M2 Class - ViewModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);
#parse("M2 PHP File Header")

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

use Magento\Framework\View\Element\Block\ArgumentInterface;

class ${NAME} implements ArgumentInterface
{
#[[$END$]]#
}
11 changes: 11 additions & 0 deletions files/fileTemplates/M2 Class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php declare(strict_types=1);
#parse("M2 PHP File Header")

#if (${NAMESPACE})
namespace ${NAMESPACE};
#end

class ${NAME}
{
#[[$END$]]#
}
7 changes: 7 additions & 0 deletions files/fileTemplates/M2 Config XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
<default>
#[[$END$]]#
</default>
</config>
5 changes: 5 additions & 0 deletions files/fileTemplates/M2 DI.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
#[[$END$]]#
</config>
5 changes: 5 additions & 0 deletions files/fileTemplates/M2 Db schema XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
#[[$END$]]#
</schema>
5 changes: 5 additions & 0 deletions files/fileTemplates/M2 Extension Attributes XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
#[[$END$]]#
</config>
7 changes: 7 additions & 0 deletions files/fileTemplates/M2 Layout XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
#[[$END$]]#
</body>
</page>
5 changes: 5 additions & 0 deletions files/fileTemplates/M2 Module XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
m2module#[[$END$]]#
</config>
11 changes: 11 additions & 0 deletions files/fileTemplates/M2 Registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
#parse("M2 PHP File Header")

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(
ComponentRegistrar::MODULE,
'${Vendor}_${Namespace}',
__DIR__
);
#[[$END$]]#
9 changes: 9 additions & 0 deletions files/fileTemplates/M2 Sales XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Sales:etc/sales.xsd">
<section name="quote">
<group name="totals">
#[[$END$]]#
</group>
</section>
</config>
7 changes: 7 additions & 0 deletions files/fileTemplates/M2 System XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
#[[$END$]]#
</system>
</config>
5 changes: 5 additions & 0 deletions files/fileTemplates/M2 System include XML.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
#parse("M2 XML File Header")
<include xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_include.xsd">
#[[$END$]]#
</include>
6 changes: 0 additions & 6 deletions files/fileTemplates/code/PHP Constructor.php

This file was deleted.

11 changes: 0 additions & 11 deletions files/fileTemplates/code/PHP Fluent Setter Method.php

This file was deleted.

Loading

0 comments on commit 27afeca

Please sign in to comment.