Skip to content

Commit e8ab0a1

Browse files
authored
Merge branch '2.1.0-develop' into tests-06
2 parents 12c722f + 3b37a61 commit e8ab0a1

File tree

44 files changed

+1987
-222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1987
-222
lines changed

resources/META-INF/plugin.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<action id="MagentoCreateCLICommand" class="com.magento.idea.magento2plugin.actions.generation.NewCLICommandAction" />
6868
<action id="MagentoCreateUiComponentGrid" class="com.magento.idea.magento2plugin.actions.generation.NewUiComponentGridAction" />
6969
<action id="MagentoCreateUiComponentForm" class="com.magento.idea.magento2plugin.actions.generation.NewUiComponentFormAction" />
70+
<action id="NewModelsAction" class="com.magento.idea.magento2plugin.actions.generation.NewModelsAction" />
7071
<add-to-group group-id="NewGroup" anchor="last"/>
7172
</group>
7273

@@ -210,6 +211,9 @@
210211
<internalFileTemplate name="Magento Routes XML"/>
211212
<internalFileTemplate name="Magento Layout XML"/>
212213
<internalFileTemplate name="Magento ACL XML"/>
214+
<internalFileTemplate name="Magento Collection Class"/>
215+
<internalFileTemplate name="Magento Model Class"/>
216+
<internalFileTemplate name="Magento Resource Model Class"/>
213217

214218
<defaultLiveTemplates file="/liveTemplates/MagentoPWA.xml"/>
215219

resources/fileTemplates/code/Magento Module UI Component Form Field Xml.xml.html

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,5 @@
66
-->
77
<html lang="en">
88
<body>
9-
<p face="verdana" size="-1">
10-
The <a href="https://devdocs.magento.com/guides/v2.4/ui_comp_guide/components/ui-form.html">Form component</a> configuration.
11-
</p>
12-
13-
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
14-
<tr>
15-
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
16-
</tr>
17-
<tr>
18-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
19-
<td width="10">&nbsp;</td>
20-
<td width="100%" valign="top"><font face="verdana" size="-1">Name for the UI Component Form. The name will be used for configuration file.</font></td>
21-
</tr>
22-
<tr>
23-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${LABEL}</b></font></nobr></td>
24-
<td width="10">&nbsp;</td>
25-
<td width="100%" valign="top"><font face="verdana" size="-1">Label for form elements (fieldset, button, input, etc..)</font></td>
26-
</tr>
27-
<tr>
28-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${BUTTONS}</b></font></nobr></td>
29-
<td width="10">&nbsp;</td>
30-
<td width="100%" valign="top"><font face="verdana" size="-1">Buttons that should be added to form.</font></td>
31-
</tr>
32-
<tr>
33-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${ROUTE}</b></font></nobr></td>
34-
<td width="10">&nbsp;</td>
35-
<td width="100%" valign="top"><font face="verdana" size="-1">Route name</font></td>
36-
</tr>
37-
<tr>
38-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SUBMIT_CONTROLLER}</b></font></nobr></td>
39-
<td width="10">&nbsp;</td>
40-
<td width="100%" valign="top"><font face="verdana" size="-1">Class name for the controller.</font></td>
41-
</tr>
42-
<tr>
43-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SUBMIT_ACTION}</b></font></nobr></td>
44-
<td width="10">&nbsp;</td>
45-
<td width="100%" valign="top"><font face="verdana" size="-1">Specifies the action class name.</font></td>
46-
</tr>
47-
<tr>
48-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${DATA_PROVIDER}</b></font></nobr></td>
49-
<td width="10">&nbsp;</td>
50-
<td width="100%" valign="top"><font face="verdana" size="-1">Class name for the data provider class.</font></td>
51-
</tr>
52-
<tr>
53-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${PRIMARY_FIELD}</b></font></nobr></td>
54-
<td width="10">&nbsp;</td>
55-
<td width="100%" valign="top"><font face="verdana" size="-1">Resource model primary field name.</font></td>
56-
</tr>
57-
</table>
589
</body>
59-
</html>
10+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
8+
#set ($uses = ${USES})
9+
#foreach ($use in $uses.split(","))
10+
use $use;
11+
#end
12+
13+
class ${NAME}#if (${EXTENDS}) extends ${EXTENDS}#end#if (${IMPLEMENTS}) implements ${IMPLEMENTS}#end {
14+
/**
15+
* @var string
16+
*/
17+
protected $_eventPrefix = '${DB_NAME}_collection';
18+
19+
/**
20+
* @inheritdoc
21+
*/
22+
protected function _construct()
23+
{
24+
$this->_init(${MODEL}::class, ${RESOURCE_MODEL}::class);
25+
}
26+
}

resources/fileTemplates/internal/Magento Collection Class.php.html

Whitespace-only changes.

resources/fileTemplates/internal/Magento Form Button Block Class.php.html

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,54 +6,5 @@
66
-->
77
<html lang="en">
88
<body>
9-
<p face="verdana" size="-1">
10-
The <a href="https://devdocs.magento.com/guides/v2.4/ui_comp_guide/components/ui-form.html">Form component</a> configuration.
11-
</p>
12-
13-
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
14-
<tr>
15-
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
16-
</tr>
17-
<tr>
18-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
19-
<td width="10">&nbsp;</td>
20-
<td width="100%" valign="top"><font face="verdana" size="-1">Name for the UI Component Form. The name will be used for configuration file.</font></td>
21-
</tr>
22-
<tr>
23-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${LABEL}</b></font></nobr></td>
24-
<td width="10">&nbsp;</td>
25-
<td width="100%" valign="top"><font face="verdana" size="-1">Label for form elements (fieldset, button, input, etc..)</font></td>
26-
</tr>
27-
<tr>
28-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${BUTTONS}</b></font></nobr></td>
29-
<td width="10">&nbsp;</td>
30-
<td width="100%" valign="top"><font face="verdana" size="-1">Buttons that should be added to form.</font></td>
31-
</tr>
32-
<tr>
33-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${ROUTE}</b></font></nobr></td>
34-
<td width="10">&nbsp;</td>
35-
<td width="100%" valign="top"><font face="verdana" size="-1">Route name</font></td>
36-
</tr>
37-
<tr>
38-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SUBMIT_CONTROLLER}</b></font></nobr></td>
39-
<td width="10">&nbsp;</td>
40-
<td width="100%" valign="top"><font face="verdana" size="-1">Class name for the controller.</font></td>
41-
</tr>
42-
<tr>
43-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SUBMIT_ACTION}</b></font></nobr></td>
44-
<td width="10">&nbsp;</td>
45-
<td width="100%" valign="top"><font face="verdana" size="-1">Specifies the action class name.</font></td>
46-
</tr>
47-
<tr>
48-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${DATA_PROVIDER}</b></font></nobr></td>
49-
<td width="10">&nbsp;</td>
50-
<td width="100%" valign="top"><font face="verdana" size="-1">Class name for the data provider class.</font></td>
51-
</tr>
52-
<tr>
53-
<td valign="top"><nobr><font face="verdana" size="-2"><b>${PRIMARY_FIELD}</b></font></nobr></td>
54-
<td width="10">&nbsp;</td>
55-
<td width="100%" valign="top"><font face="verdana" size="-1">Resource model primary field name.</font></td>
56-
</tr>
57-
</table>
589
</body>
5910
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
8+
#set ($uses = ${USES})
9+
#foreach ($use in $uses.split(","))
10+
use $use;
11+
#end
12+
13+
class ${NAME}#if (${EXTENDS}) extends ${EXTENDS}#end#if (${IMPLEMENTS}) implements ${IMPLEMENTS}#end {
14+
/**
15+
* @var string
16+
*/
17+
protected $_eventPrefix = '${DB_NAME}_model';
18+
19+
/**
20+
* @inheritdoc
21+
*/
22+
protected function _construct()
23+
{
24+
$this->_init(${RESOURCE_MODEL}::class);
25+
}
26+
}

resources/fileTemplates/internal/Magento Model Class.php.html

Whitespace-only changes.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
#if (${NAMESPACE})
4+
5+
namespace ${NAMESPACE};
6+
#end
7+
8+
#set ($uses = ${USES})
9+
#foreach ($use in $uses.split(","))
10+
use $use;
11+
#end
12+
13+
class ${NAME}#if (${EXTENDS}) extends ${EXTENDS}#end#if (${IMPLEMENTS}) implements ${IMPLEMENTS}#end {
14+
/**
15+
* @var string
16+
*/
17+
protected $_eventPrefix = '${DB_NAME}_resource_model';
18+
19+
/**
20+
* @inheritdoc
21+
*/
22+
protected function _construct()
23+
{
24+
$this->_init('${DB_NAME}', '${ENTITY_ID_COLUMN}');
25+
}
26+
}

resources/fileTemplates/internal/Magento Resource Model Class.php.html

Whitespace-only changes.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.NewModelsDialog;
18+
19+
public class NewModelsAction extends AnAction {
20+
public static final String ACTION_NAME = "Magento 2 Models";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 models";
22+
23+
/**
24+
* New controller action constructor.
25+
*/
26+
public NewModelsAction() {
27+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
28+
}
29+
30+
@Override
31+
public void actionPerformed(final AnActionEvent event) {
32+
final DataContext dataContext = event.getDataContext();
33+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
34+
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+
49+
NewModelsDialog.open(project, directory);
50+
}
51+
52+
@Override
53+
public boolean isDumbAware() {
54+
return false;
55+
}
56+
}

0 commit comments

Comments
 (0)