Skip to content

Commit 1c57015

Browse files
author
Sergiy Zhovnir
committed
#issue-57 Adjusted the new controller action
1 parent f75bf1f commit 1c57015

18 files changed

+402
-220
lines changed

resources/META-INF/plugin.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@
162162
<internalFileTemplate name="Magento GraphQL Resolver Class"/>
163163
<internalFileTemplate name="Magento Cronjob Class"/>
164164
<internalFileTemplate name="Magento Crontab Xml"/>
165+
<internalFileTemplate name="Magento Module Controller Backend Class"/>
166+
<internalFileTemplate name="Magento Module Controller Frontend Class"/>
165167
</extensions>
166168

167169
<extensions defaultExtensionNs="com.jetbrains.php">

resources/fileTemplates/code/Magento Controller Class Body.php.ft

Lines changed: 0 additions & 17 deletions
This file was deleted.

resources/fileTemplates/code/Magento Controller Class Body.php.html

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
#if (${ACL})
15+
/**
16+
* Authorization level of a basic admin session
17+
*/
18+
const ADMIN_RESOURCE = '${ACL}';
19+
20+
#end
21+
/**
22+
* Execute action based on request and return result
23+
*
24+
* @return ResultInterface|ResponseInterface
25+
* @throws NotFoundException
26+
*/
27+
public function execute()
28+
{
29+
// TODO: Implement execute method.
30+
}
31+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td>
12+
<font face="verdana" size="-1">
13+
Action classes are extensions of the Action class that a router returns on matched requests.
14+
Each Action should implement Magento\Framework\App\Action\HttpHTTP MethodActionInterface to declare which HTTP request methods it can process.
15+
The <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/App/ActionInterface.php#L34">execute()</a> function in these classes contain the logic for dispatching requests.
16+
Action class should return a <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/Controller/ResultInterface.php">result</a> object.
17+
Backend Controller allows to restrict an access by ACL.
18+
</font><br>
19+
</td>
20+
</tr>
21+
<tr>
22+
<td><font face="verdana" size="-1">
23+
<a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/routing.html#action-class">Read more</a> about Controller Action, including when those can be used.
24+
</font><br>
25+
</td>
26+
</tr>
27+
</table>
28+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
29+
<tr>
30+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
31+
</tr>
32+
<tr>
33+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
34+
<td width="10">&nbsp;</td>
35+
<td width="100%" valign="top"><font face="verdana" size="-1">Created PHP Controller Action class namespace.</font></td>
36+
</tr>
37+
<tr>
38+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
39+
<td width="10">&nbsp;</td>
40+
<td width="100%" valign="top"><font face="verdana" size="-1">PHP class for the Controller Action name.</font></td>
41+
</tr>
42+
<tr>
43+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${EXTENDS}</b></font></nobr></td>
44+
<td width="10">&nbsp;</td>
45+
<td width="100%" valign="top"><font face="verdana" size="-1">Name of PHP class that the Controller Action extends.</font></td>
46+
</tr>
47+
<tr>
48+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${IMPLEMENTS}</b></font></nobr></td>
49+
<td width="10">&nbsp;</td>
50+
<td width="100%" valign="top"><font face="verdana" size="-1">Name of PHP interface that the Controller Action implements.</font></td>
51+
</tr>
52+
<tr>
53+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${USES}</b></font></nobr></td>
54+
<td width="10">&nbsp;</td>
55+
<td width="100%" valign="top"><font face="verdana" size="-1">List of imports separated by comma.</font></td>
56+
</tr>
57+
<tr>
58+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${ACL}</b></font></nobr></td>
59+
<td width="10">&nbsp;</td>
60+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of ACL resource that allows to restrict an access to the backend controller action.</font></td>
61+
</tr>
62+
</table>
63+
</body>
64+
</html>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
* Execute action based on request and return result
16+
*
17+
* @return ResultInterface|ResponseInterface
18+
* @throws NotFoundException
19+
*/
20+
public function execute()
21+
{
22+
// TODO: Implement execute method.
23+
}
24+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<!--
2+
/*
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
-->
7+
<html>
8+
<body>
9+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
10+
<tr>
11+
<td>
12+
<font face="verdana" size="-1">
13+
Action classes are extensions of the Action class that a router returns on matched requests.
14+
Each Action should implement Magento\Framework\App\Action\HttpHTTP MethodActionInterface to declare which HTTP request methods it can process.
15+
The <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/App/ActionInterface.php#L34">execute()</a> function in these classes contain the logic for dispatching requests.
16+
Action class should return a <a href="https://github.com/magento/magento2/blob/2.3/lib/internal/Magento/Framework/Controller/ResultInterface.php">result</a> object.
17+
</font><br>
18+
</td>
19+
</tr>
20+
<tr>
21+
<td><font face="verdana" size="-1">
22+
<a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/routing.html#action-class">Read more</a> about Controller Action, including when those can be used.
23+
</font><br>
24+
</td>
25+
</tr>
26+
</table>
27+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
28+
<tr>
29+
<td colspan="3"><font face="verdana" size="-1">Predefined variables will take the following values:</font></td>
30+
</tr>
31+
<tr>
32+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
33+
<td width="10">&nbsp;</td>
34+
<td width="100%" valign="top"><font face="verdana" size="-1">Created PHP Controller Action class namespace.</font></td>
35+
</tr>
36+
<tr>
37+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
38+
<td width="10">&nbsp;</td>
39+
<td width="100%" valign="top"><font face="verdana" size="-1">PHP class for the Controller Action name.</font></td>
40+
</tr>
41+
<tr>
42+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${EXTENDS}</b></font></nobr></td>
43+
<td width="10">&nbsp;</td>
44+
<td width="100%" valign="top"><font face="verdana" size="-1">Name of PHP class that the Controller Action extends.</font></td>
45+
</tr>
46+
<tr>
47+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${IMPLEMENTS}</b></font></nobr></td>
48+
<td width="10">&nbsp;</td>
49+
<td width="100%" valign="top"><font face="verdana" size="-1">Name of PHP interface that the Controller Action implements.</font></td>
50+
</tr>
51+
<tr>
52+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${USES}</b></font></nobr></td>
53+
<td width="10">&nbsp;</td>
54+
<td width="100%" valign="top"><font face="verdana" size="-1">List of imports separated by comma.</font></td>
55+
</tr>
56+
</table>
57+
</body>
58+
</html>

resources/magento2/common.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ common.module.version=Module Version
44
common.module.license=Module's license(s)
55
common.module.dependencies=Module Dependencies
66
common.module.description=Module Description
7+
common.controller.area=Controller Area
8+
common.controller.name=Controller Name
9+
common.controller.parentDir=Controller Parent Directory
10+
common.controller.httpMethod=HTTP Method
11+
common.controller.inheritAction=Inherit Action Class
12+
common.controller.backend.acl=Admin Resource ACL
13+
common.controller.action=Controller Action
714
common.ok=OK
815
common.cancel=Cancel
916
common.error=Error

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewControllerDialog.form

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
3737
</constraints>
3838
<properties>
39-
<text value="OK"/>
39+
<text resource-bundle="magento2/common" key="common.ok"/>
4040
</properties>
4141
</component>
4242
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
4343
<constraints>
4444
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
4545
</constraints>
4646
<properties>
47-
<text value="Cancel"/>
47+
<text resource-bundle="magento2/common" key="common.cancel"/>
4848
</properties>
4949
</component>
5050
</children>
@@ -64,7 +64,7 @@
6464
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
6565
</constraints>
6666
<properties>
67-
<text value="Controller Name"/>
67+
<text resource-bundle="magento2/common" key="common.controller.name"/>
6868
</properties>
6969
</component>
7070
<component id="4e6cb" class="javax.swing.JTextField" binding="controllerName">
@@ -82,7 +82,7 @@
8282
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
8383
</constraints>
8484
<properties>
85-
<text value="Controller Parent Directory"/>
85+
<text resource-bundle="magento2/common" key="common.controller.parentDir"/>
8686
</properties>
8787
</component>
8888
<component id="7df01" class="javax.swing.JTextField" binding="controllerParentDir">
@@ -100,7 +100,7 @@
100100
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
101101
</constraints>
102102
<properties>
103-
<text value="Action Name"/>
103+
<text resource-bundle="magento2/common" key="common.controller.action"/>
104104
</properties>
105105
</component>
106106
<component id="7b9f6" class="javax.swing.JTextField" binding="actionName">
@@ -129,15 +129,15 @@
129129
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
130130
</constraints>
131131
<properties>
132-
<text value="Controller Area"/>
132+
<text resource-bundle="magento2/common" key="common.controller.area"/>
133133
</properties>
134134
</component>
135135
<component id="b8f6d" class="javax.swing.JLabel">
136136
<constraints>
137137
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
138138
</constraints>
139139
<properties>
140-
<text value="HTTP Method"/>
140+
<text resource-bundle="magento2/common" key="common.controller.httpMethod"/>
141141
</properties>
142142
</component>
143143
<component id="3eabb" class="com.magento.idea.magento2plugin.ui.FilteredComboBox" binding="httpMethodSelect" custom-create="true">
@@ -156,7 +156,7 @@
156156
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
157157
</constraints>
158158
<properties>
159-
<text value="Inherit Action Class"/>
159+
<text resource-bundle="magento2/common" key="common.controller.inheritAction"/>
160160
</properties>
161161
</component>
162162
<grid id="5b6ca" binding="AdminPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
@@ -183,7 +183,7 @@
183183
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
184184
</constraints>
185185
<properties>
186-
<text value="Admin Resource ACL"/>
186+
<text resource-bundle="magento2/common" key="common.controller.backend.acl"/>
187187
</properties>
188188
</component>
189189
</children>

0 commit comments

Comments
 (0)