Skip to content

Commit 374ecef

Browse files
authored
Merge pull request #350 from serhiyzhovnir/feature/issue-179
#issue-179 Added email template generation
2 parents 264c5ef + 421c3eb commit 374ecef

27 files changed

+1638
-0
lines changed

resources/META-INF/plugin.xml

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
<action id="MagentoCreateAViewModel" class="com.magento.idea.magento2plugin.actions.generation.NewViewModelAction" />
6666
<action id="MagentoCreateAGraphQlResolver" class="com.magento.idea.magento2plugin.actions.generation.NewGraphQlResolverAction" />
6767
<action id="MagentoCreateCLICommand" class="com.magento.idea.magento2plugin.actions.generation.NewCLICommandAction" />
68+
<action id="MagentoCreateEmailTemplate" class="com.magento.idea.magento2plugin.actions.generation.NewEmailTemplateAction" />
6869
<action id="MagentoCreateUiComponentGrid" class="com.magento.idea.magento2plugin.actions.generation.NewUiComponentGridAction" />
6970
<action id="MagentoCreateUiComponentForm" class="com.magento.idea.magento2plugin.actions.generation.NewUiComponentFormAction" />
7071
<action id="NewModelsAction" class="com.magento.idea.magento2plugin.actions.generation.NewModelsAction" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<template id="${ID}" label="${LABEL}" file="${FILE_NAME}.html" type="${TYPE}" module="${MODULE}" area="${AREA}"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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">Email templates configuration.</font>
13+
</td>
14+
</tr>
15+
</table>
16+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
17+
<tr>
18+
<td colspan="3"><font face="verdana" size="-1">Predefined variables explanation:</font></td>
19+
</tr>
20+
<tr>
21+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${ID}</b></font></nobr></td>
22+
<td width="10">&nbsp;</td>
23+
<td width="100%" valign="top"><font face="verdana" size="-1">Email template ID.</font></td>
24+
</tr>
25+
<tr>
26+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${LABEL}</b></font></nobr></td>
27+
<td width="10">&nbsp;</td>
28+
<td width="100%" valign="top"><font face="verdana" size="-1">Email Template Label.</font></td>
29+
</tr>
30+
<tr>
31+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${FILE_NAME}</b></font></nobr></td>
32+
<td width="10">&nbsp;</td>
33+
<td width="100%" valign="top"><font face="verdana" size="-1">Email template file name.</font></td>
34+
</tr>
35+
<tr>
36+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${TYPE}</b></font></nobr></td>
37+
<td width="10">&nbsp;</td>
38+
<td width="100%" valign="top"><font face="verdana" size="-1">Email template type. (HTML or TEXT)</font></td>
39+
</tr>
40+
<tr>
41+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${MODULE}</b></font></nobr></td>
42+
<td width="10">&nbsp;</td>
43+
<td width="100%" valign="top"><font face="verdana" size="-1">Module's name.</font></td>
44+
</tr>
45+
<tr>
46+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${AREA}</b></font></nobr></td>
47+
<td width="10">&nbsp;</td>
48+
<td width="100%" valign="top"><font face="verdana" size="-1">Email template area. (Adminhtml or Frontend)</font></td>
49+
</tr>
50+
</table>
51+
</body>
52+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--@subject {{trans "${SUBJECT}"}} @-->
2+
<!--@vars {} @-->
3+
4+
#if (${HTML_TYPE}){{template config_path="design/email/header_template"}}#end
5+
6+
<!-- @todo: implement ${TYPE} template -->
7+
#if (${HTML_TYPE}){{template config_path="design/email/footer_template"}}#end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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">Email template.</font>
13+
</td>
14+
</tr>
15+
</table>
16+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
17+
<tr>
18+
<td colspan="3"><font face="verdana" size="-1">Predefined variables explanation:</font></td>
19+
</tr>
20+
<tr>
21+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SUBJECT}</b></font></nobr></td>
22+
<td width="10">&nbsp;</td>
23+
<td width="100%" valign="top"><font face="verdana" size="-1">Email subject.</font></td>
24+
</tr>
25+
<tr>
26+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${HTML_TYPE}</b></font></nobr></td>
27+
<td width="10">&nbsp;</td>
28+
<td width="100%" valign="top"><font face="verdana" size="-1">Defines if it's HTML type template.</font></td>
29+
</tr>
30+
<tr>
31+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${TYPE}</b></font></nobr></td>
32+
<td width="10">&nbsp;</td>
33+
<td width="100%" valign="top"><font face="verdana" size="-1">Email template type. (HTML or TEXT)</font></td>
34+
</tr>
35+
</table>
36+
</body>
37+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd">
4+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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">Email templates configurations.</font>
13+
</td>
14+
</tr>
15+
</table>
16+
</body>
17+
</html>

resources/magento2/common.properties

+5
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,8 @@ common.addToolbarFullTextSearch=Add Toolbar Full Text Search
6464
common.addToolbarColumnsControl=Add Toolbar Columns Control
6565
common.addToolbarBookmarks=Add Toolbar Bookmarks
6666
common.argument=Argument name
67+
common.template.id=Template ID
68+
common.template.label=Template Label
69+
common.template.filename=Template File Name
70+
common.template.subject=Email Subject
71+
common.template.type=Email Type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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.NewEmailTemplateDialog;
18+
19+
@SuppressWarnings({"PMD.OnlyOneReturn", "PMD.FieldNamingConventions"})
20+
public class NewEmailTemplateAction extends AnAction {
21+
public static final String ACTION_NAME = "Magento 2 Email Template";
22+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 email template";
23+
24+
/**
25+
* New email template action constructor.
26+
*/
27+
public NewEmailTemplateAction() {
28+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
29+
}
30+
31+
@Override
32+
public void actionPerformed(final AnActionEvent event) {
33+
final DataContext dataContext = event.getDataContext();
34+
final IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
35+
36+
if (view == null) {
37+
return;
38+
}
39+
40+
final Project project = CommonDataKeys.PROJECT.getData(dataContext);
41+
if (project == null) {
42+
return;
43+
}
44+
45+
final PsiDirectory directory = view.getOrChooseDirectory();
46+
if (directory == null) {
47+
return;
48+
}
49+
50+
NewEmailTemplateDialog.open(project, directory);
51+
}
52+
53+
@Override
54+
public boolean isDumbAware() {
55+
return false;
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
@SuppressWarnings({"PMD.DataClass"})
9+
public class EmailTemplateHtmlData {
10+
private final String module;
11+
private final String fileName;
12+
private final String area;
13+
private final String subject;
14+
private final String type;
15+
16+
/**
17+
* Email template HTML data constructor.
18+
*
19+
* @param module String
20+
* @param area String
21+
* @param subject String
22+
* @param type String
23+
*/
24+
public EmailTemplateHtmlData(
25+
final String module,
26+
final String fileName,
27+
final String area,
28+
final String subject,
29+
final String type
30+
) {
31+
this.module = module;
32+
this.fileName = fileName;
33+
this.area = area;
34+
this.subject = subject;
35+
this.type = type;
36+
}
37+
38+
/**
39+
* Get module name.
40+
*
41+
* @return String
42+
*/
43+
public String getModule() {
44+
return module;
45+
}
46+
47+
/**
48+
* Get file name.
49+
*
50+
* @return String
51+
*/
52+
public String getFileName() {
53+
return fileName;
54+
}
55+
56+
/**
57+
* Get area.
58+
*
59+
* @return String
60+
*/
61+
public String getArea() {
62+
return area;
63+
}
64+
65+
/**
66+
* Get subject.
67+
*
68+
* @return String
69+
*/
70+
public String getSubject() {
71+
return subject;
72+
}
73+
74+
/**
75+
* Get type.
76+
*
77+
* @return String
78+
*/
79+
public String getType() {
80+
return type;
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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+
@SuppressWarnings({"PMD.DataClass"})
9+
public class EmailTemplatesXmlData {
10+
private final String module;
11+
private final String emailTemplateId;
12+
private final String label;
13+
private final String templateFileName;
14+
private final String type;
15+
private final String area;
16+
17+
/**
18+
* Email templates data constructor.
19+
*
20+
* @param module String
21+
* @param emailTemplateId String
22+
* @param label String
23+
* @param templateFileName String
24+
* @param type String
25+
* @param area String
26+
*/
27+
public EmailTemplatesXmlData(
28+
final String module,
29+
final String emailTemplateId,
30+
final String label,
31+
final String templateFileName,
32+
final String type,
33+
final String area
34+
) {
35+
this.module = module;
36+
this.emailTemplateId = emailTemplateId;
37+
this.label = label;
38+
this.templateFileName = templateFileName;
39+
this.type = type;
40+
this.area = area;
41+
}
42+
43+
/**
44+
* Get template file name.
45+
*
46+
* @return String
47+
*/
48+
public String getTemplateFileName() {
49+
return templateFileName;
50+
}
51+
52+
/**
53+
* Get ID.
54+
*
55+
* @return String
56+
*/
57+
public String getId() {
58+
return emailTemplateId;
59+
}
60+
61+
/**
62+
* Get label.
63+
*
64+
* @return String
65+
*/
66+
public String getLabel() {
67+
return label;
68+
}
69+
70+
/**
71+
* Get module.
72+
*
73+
* @return String
74+
*/
75+
public String getModule() {
76+
return module;
77+
}
78+
79+
/**
80+
* Get type.
81+
*
82+
* @return String
83+
*/
84+
public String getType() {
85+
return type;
86+
}
87+
88+
/**
89+
* Get area.
90+
*
91+
* @return String
92+
*/
93+
public String getArea() {
94+
return area;
95+
}
96+
}

0 commit comments

Comments
 (0)