Skip to content

Commit 8e1df95

Browse files
author
Vitaliy
authored
Merge branch '3.1.0-develop' into issue-423
2 parents 070fe6d + ff20eae commit 8e1df95

31 files changed

+2397
-6
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1+
<p align="center">
2+
<a href="https://magento.com">
3+
<img src="https://static.magento.com/sites/all/themes/magento/logo.svg" width="300px" alt="Magento Commerce" />
4+
</a>
5+
</p>
6+
17
# PhpStorm Magento 2 Plugin
28

39
[![Version](http://phpstorm.espend.de/badge/8024/version)](https://plugins.jetbrains.com/plugin/8024)
410
[![Downloads](http://phpstorm.espend.de/badge/8024/downloads)](https://plugins.jetbrains.com/plugin/8024)
5-
[![Downloads last month](http://phpstorm.espend.de/badge/8024/last-month)](https://plugins.jetbrains.com/plugin/8024)
6-
7-
This is a PhpStorm IDE plugin for a better Magento 2 development workflow. It is available via the [JetBrains Plugin Repository](https://plugins.jetbrains.com/plugin/8024)
11+
![merge-chance-badge](https://img.shields.io/endpoint?url=https%3A%2F%2Fmerge-chance.info%2Fbadge%3Frepo%3Dmagento/magento2-phpstorm-plugin)
812

913
## Installation
1014

gradle-tasks/pmd/ruleset.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
</rule>
3838
<exclude-pattern>.*/resources/.*</exclude-pattern>
3939
<exclude-pattern>.*/testData/.*</exclude-pattern>
40-
<rule ref="category/java/multithreading.xml"/>
40+
<rule ref="category/java/multithreading.xml">
41+
<exclude name="UseConcurrentHashMap" />
42+
</rule>
4143
<rule ref="category/java/performance.xml"/>
4244
<rule ref="category/java/security.xml" />
4345
</ruleset>

resources/META-INF/plugin.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<action id="NewModelsAction" class="com.magento.idea.magento2plugin.actions.generation.NewModelsAction" />
7171
<action id="MagentoCreateADataModel" class="com.magento.idea.magento2plugin.actions.generation.NewDataModelAction" />
7272
<action id="MagentoMessageQueue" class="com.magento.idea.magento2plugin.actions.generation.NewMessageQueueAction" />
73+
<action id="NewDbSchema" class="com.magento.idea.magento2plugin.actions.generation.NewDbSchemaAction" />
7374
<add-to-group group-id="NewGroup" anchor="last"/>
7475
</group>
7576

@@ -224,6 +225,8 @@
224225
<internalFileTemplate name="Magento Resource Model Class"/>
225226
<internalFileTemplate name="Magento Data Model"/>
226227
<internalFileTemplate name="Magento Data Model Interface"/>
228+
<internalFileTemplate name="Magento Module Declarative Schema XML"/>
229+
<internalFileTemplate name="Magento Module Declarative Schema Whitelist JSON"/>
227230

228231
<defaultLiveTemplates file="/liveTemplates/MagentoPWA.xml"/>
229232

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
#if (${TABLE_NAME})
3+
"${TABLE_NAME}": {
4+
#if (${COLUMNS})
5+
"column": {
6+
#set ($columns = ${COLUMNS})
7+
#foreach ($column in $columns)
8+
"$column": true,
9+
#end
10+
},
11+
#end
12+
#if (${INDEXES})
13+
"index": {
14+
#set ($indexes = ${INDEXES})
15+
#foreach ($index in $indexes)
16+
"$index": true,
17+
#end
18+
},
19+
#end
20+
#if (${CONSTRAINTS})
21+
"constraint": {
22+
#set ($constraints = ${CONSTRAINTS})
23+
#foreach ($constraint in $constraints)
24+
"$constraint": true,
25+
#end
26+
}
27+
#end
28+
}
29+
#end
30+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<html lang="en">
2+
<body>
3+
<p face="verdana" size="-1">
4+
The db_schema_whitelist.json file provides a history of all tables, columns, and keys added with declarative schema. It is required to allow drop operations.<br>
5+
</p>
6+
<p>
7+
Read more about <a href="https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/migration-commands.html#create-whitelist">Create a schema whitelist</a>.
8+
</p>
9+
<p>
10+
The magento 2 whitelist generation command gets INDEX and CONSTRAINTS referenceId from the real database, db_schema.xml data used only as recommendations.
11+
Please, pay attention, in the PHP Storm file generation referenceId used from the db_schema.xml file and should be checked from the real database.
12+
</p>
13+
14+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
15+
<tr>
16+
<td colspan="3"><font face="verdana" size="-1">Template's predefined variables:</font></td>
17+
</tr>
18+
<tr>
19+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${TABLE_NAME}</b></font></nobr></td>
20+
<td width="10">&nbsp;</td>
21+
<td width="100%" valign="top"><font face="verdana" size="-1">Database table name.</font></td>
22+
</tr>
23+
<tr>
24+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${COLUMNS}</b></font></nobr></td>
25+
<td width="10">&nbsp;</td>
26+
<td width="100%" valign="top"><font face="verdana" size="-1">Database table columns names.</font></td>
27+
</tr>
28+
<tr>
29+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${INDEXES}</b></font></nobr></td>
30+
<td width="10">&nbsp;</td>
31+
<td width="100%" valign="top"><font face="verdana" size="-1">Database table indexes names.</font></td>
32+
</tr>
33+
<tr>
34+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${CONSTRAINTS}</b></font></nobr></td>
35+
<td width="10">&nbsp;</td>
36+
<td width="100%" valign="top"><font face="verdana" size="-1">Database table constraints names.</font></td>
37+
</tr>
38+
</table>
39+
</body>
40+
</html>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Setup/Declaration/Schema/etc/schema.xsd">
4+
</schema>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html lang="en">
8+
<body>
9+
<font face="verdana" size="-1">
10+
<p>
11+
Declarative Schema aims to simplify the Magento installation and upgrade processes. The new declarative schema approach allows developers to declare the final desired state of the database and has the system adjust to it automatically, without performing redundant operations. Developers are no longer forced to write scripts for each new version. In addition, this approach allows data be deleted when a module is uninstalled.
12+
</p>
13+
<p>
14+
Read more about <a href="https://devdocs.magento.com/guides/v2.4/extension-dev-guide/declarative-schema/">Declarative Schema Overview</a>.
15+
</p>
16+
</font>
17+
</body>
18+
</html>

resources/magento2/validation.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ validator.mustNotBeEmptyShouldContainLettersOrNumbers=Must not be empty, should
3333
validator.magentoRouteIdInvalid=The route id is invalid
3434
validator.magentoAclResourceIdInvalid=The ACL resource id is invalid
3535
validator.lowercaseCharacters={0} must contain lowercase characters only
36+
validator.db.invalidTableNameLength=Table name must contain up to 64 characters only (inclusive)
3637
validator.lowerSnakeCase=The {0} field must be of the lower snake case format
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation;
7+
8+
import com.intellij.ide.IdeView;
9+
import com.intellij.openapi.actionSystem.AnAction;
10+
import com.intellij.openapi.actionSystem.AnActionEvent;
11+
import com.intellij.openapi.actionSystem.CommonDataKeys;
12+
import com.intellij.openapi.actionSystem.DataContext;
13+
import com.intellij.openapi.actionSystem.LangDataKeys;
14+
import com.intellij.openapi.project.Project;
15+
import com.intellij.psi.PsiDirectory;
16+
import com.magento.idea.magento2plugin.MagentoIcons;
17+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewDbSchemaDialog;
18+
import org.jetbrains.annotations.NotNull;
19+
20+
public class NewDbSchemaAction extends AnAction {
21+
public static final String ACTION_NAME = "Declarative Schema XML";
22+
public static final String ACTION_DESCRIPTION = "Create a new declarative schema XML";
23+
24+
/**
25+
* Constructor.
26+
*/
27+
public NewDbSchemaAction() {
28+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
29+
}
30+
31+
@Override
32+
public void actionPerformed(final @NotNull AnActionEvent event) {
33+
final DataContext dataContext = event.getDataContext();
34+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
35+
if (view == null) {
36+
return;
37+
}
38+
39+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
40+
if (project == null) {
41+
return;
42+
}
43+
44+
final PsiDirectory directory = view.getOrChooseDirectory();
45+
if (directory == null) {
46+
return;
47+
}
48+
NewDbSchemaDialog.open(project, directory);
49+
}
50+
51+
@Override
52+
public boolean isDumbAware() {
53+
return false;
54+
}
55+
}
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.generation.data;
7+
8+
import com.magento.idea.magento2plugin.magento.files.ModuleDbSchemaXml;
9+
import java.util.LinkedHashMap;
10+
import java.util.LinkedList;
11+
import java.util.List;
12+
import java.util.Map;
13+
14+
public class DbSchemaXmlData {
15+
private String tableName;
16+
private String tableResource;
17+
private String tableEngine;
18+
private String tableComment;
19+
private List<Map<String, String>> columns;
20+
21+
/**
22+
* Constructor.
23+
*
24+
* @param tableName String
25+
* @param tableResource String
26+
* @param tableEngine String
27+
* @param tableComment String
28+
* @param columns List
29+
*/
30+
public DbSchemaXmlData(
31+
final String tableName,
32+
final String tableResource,
33+
final String tableEngine,
34+
final String tableComment,
35+
final List<Map<String, String>> columns
36+
) {
37+
this.tableName = tableName;
38+
this.tableResource = tableResource;
39+
this.tableEngine = tableEngine;
40+
this.tableComment = tableComment;
41+
this.columns = columns;
42+
}
43+
44+
public String getTableName() {
45+
return tableName;
46+
}
47+
48+
public void setTableName(final String tableName) {
49+
this.tableName = tableName;
50+
}
51+
52+
public String getTableResource() {
53+
return tableResource;
54+
}
55+
56+
public void setTableResource(final String tableResource) {
57+
this.tableResource = tableResource;
58+
}
59+
60+
public String getTableEngine() {
61+
return tableEngine;
62+
}
63+
64+
public void setTableEngine(final String tableEngine) {
65+
this.tableEngine = tableEngine;
66+
}
67+
68+
public String getTableComment() {
69+
return tableComment;
70+
}
71+
72+
public void setTableComment(final String tableComment) {
73+
this.tableComment = tableComment;
74+
}
75+
76+
public List<Map<String, String>> getColumns() {
77+
return new LinkedList<>(columns);
78+
}
79+
80+
public void setColumns(final List<Map<String, String>> columns) {
81+
this.columns = columns;
82+
}
83+
84+
/**
85+
* Get table attributes values map.
86+
*
87+
* @return Map
88+
*/
89+
public Map<String, String> getTableAttributesMap() {
90+
final Map<String, String> tableAttributesData = new LinkedHashMap<>();
91+
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_NAME, getTableName());
92+
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_RESOURCE, getTableResource());
93+
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_ENGINE, getTableEngine());
94+
tableAttributesData.put(ModuleDbSchemaXml.XML_ATTR_TABLE_COMMENT, getTableComment());
95+
96+
return tableAttributesData;
97+
}
98+
}

0 commit comments

Comments
 (0)