Skip to content

Commit 246cc64

Browse files
author
Vitaliy
authored
Merge branch '1.0.0-develop' into inspection-plugin-possible-duplication
2 parents dd8ac97 + ef1ada0 commit 246cc64

File tree

8 files changed

+195
-13
lines changed

8 files changed

+195
-13
lines changed
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 lang="en">
8+
<body>
9+
<font face="verdana" size="-1">
10+
<p>
11+
events.xml file is the place where module's Observers are declared to adjust the system.
12+
</p>
13+
<p>
14+
Read more about <a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/events-and-observers.html#subscribing-to-events">Subscribing to events</a>.
15+
</p>
16+
</font>
17+
18+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
19+
<tr>
20+
<td colspan="3"><font face="verdana" size="-1">Areas where events can be used:</font></td>
21+
</tr>
22+
<tr>
23+
<td valign="top"><b>Area</b></td>
24+
<td width="10"><b>Area Code</b></td>
25+
<td width="100%" valign="top"><b>Description</b></td>
26+
</tr>
27+
<tr>
28+
<td valign="top"><nobr><font face="verdana" size="-2"><b>Global</b></font></nobr></td>
29+
<td width="10">global</td>
30+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in all areas: adminhtml, crontab, frontend, graphql, webapi_rest, webapi_soap.</font></td>
31+
</tr>
32+
<tr>
33+
<td valign="top"><nobr><font face="verdana" size="-2"><b>Admin area</b></font></nobr></td>
34+
<td width="10">adminhtml</td>
35+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in the adminhtml area only.</font></td>
36+
</tr>
37+
<tr>
38+
<td valign="top"><nobr><font face="verdana" size="-2"><b>Storefront</b></font></nobr></td>
39+
<td width="10">frontend</td>
40+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in the frontend area only.</font></td>
41+
</tr>
42+
<tr>
43+
<td valign="top"><nobr><font face="verdana" size="-2"><b>Cron</b></font></nobr></td>
44+
<td width="10">crontab</td>
45+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in the crontab area only.</font></td>
46+
</tr>
47+
<tr>
48+
<td valign="top"><nobr><font face="verdana" size="-2"><b>GraphQl</b></font></nobr></td>
49+
<td width="10">graphql</td>
50+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in the graphql area only.</font></td>
51+
</tr>
52+
<tr>
53+
<td valign="top"><nobr><font face="verdana" size="-2"><b>REST API</b></font></nobr></td>
54+
<td width="10">webapi_rest</td>
55+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in the webapi_rest area only.</font></td>
56+
</tr>
57+
<tr>
58+
<td valign="top"><nobr><font face="verdana" size="-2"><b>SOAP API</b></font></nobr></td>
59+
<td width="10">webapi_soap</td>
60+
<td width="100%" valign="top"><font face="verdana" size="-1">Observer will be executed in the webapi_soap area only,</font></td>
61+
</tr>
62+
</table>
63+
</body>
64+
</html>

resources/fileTemplates/internal/Magento Observer Class.php.ft

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ use Magento\Framework\Event\ObserverInterface;
1010
use Magento\Framework\Event\Observer;
1111

1212
class ${NAME} implements ObserverInterface {
13-
}
13+
}
Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
11
<!--
2-
/*
2+
/**
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
66
-->
7-
<html>
8-
<body>
9-
</body>
7+
<html lang="en">
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">Observers are a certain type of Magento class that can influence
13+
general behavior, performance, or change business logic. Observers are executed whenever the
14+
event they are configured to watch is dispatched by the event manager.
15+
<a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/events-and-observers.html">
16+
Read more</a> about observers.
17+
</font>
18+
</td>
19+
</tr>
20+
<tr>
21+
<td>
22+
<font face="verdana" size="-1">Check out the
23+
<a href="https://devdocs.magento.com/guides/v2.3/ext-best-practices/extension-coding/observers-bp.html">
24+
Observers best practices</a> to have a clean and professional implementation.</font>
25+
</td>
26+
</tr>
27+
</table>
28+
29+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
30+
<tr>
31+
<td colspan="3"><font face="verdana" size="-1">Template's variables:</font></td>
32+
</tr>
33+
<tr>
34+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
35+
<td width="10">&nbsp;</td>
36+
<td width="100%" valign="top"><font face="verdana" size="-1">Created PHP observer class namespace.</font></td>
37+
</tr>
38+
<tr>
39+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
40+
<td width="10">&nbsp;</td>
41+
<td width="100%" valign="top"><font face="verdana" size="-1">PHP class for the observer name.</font></td>
42+
</tr>
43+
</table>
44+
</body>
1045
</html>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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><font face="verdana" size="-1">
12+
The object manager uses the preference mappings to determine what the default implementation is for that class for a particular scope.
13+
<a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/build/di-xml-file.html#override-a-method-using-preference-nodes">
14+
For example</a>, a preference is used to override a public or protected method from a core class.
15+
</font><br>
16+
</td>
17+
</tr>
18+
<tr>
19+
<td><font face="verdana" size="-1">
20+
Read more Abbout the preferences in the <a href="https://devdocs.magento.com/guides/v2.3/extension-dev-guide/build/di-xml-file.html#abstraction-implementation-mappings">DevDocs</a>.
21+
</font><br>
22+
</td>
23+
</tr
24+
</table>
25+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
26+
<tr>
27+
<td colspan="3"><font face="verdana" size="-1">Predefined variables explanation:</font></td>
28+
</tr>
29+
<tr>
30+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
31+
<td width="10">&nbsp;</td>
32+
<td width="100%" valign="top"><font face="verdana" size="-1">Preference's namespace.</font></td>
33+
</tr>
34+
<tr>
35+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${USE}</b></font></nobr></td>
36+
<td width="10">&nbsp;</td>
37+
<td width="100%" valign="top"><font face="verdana" size="-1">The namespace of the PHP class to extend from.</font></td>
38+
</tr>
39+
<tr>
40+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAME}</b></font></nobr></td>
41+
<td width="10">&nbsp;</td>
42+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of PHP class.</font></td>
43+
</tr>
44+
<tr>
45+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${EXTENDS}</b></font></nobr></td>
46+
<td width="10">&nbsp;</td>
47+
<td width="100%" valign="top"><font face="verdana" size="-1">The name of the PHP class to extend from.</font></td>
48+
</tr>
49+
</table>
50+
</body>
51+
</html>

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.magento.idea.magento2plugin.actions.generation.util.NavigateToCreatedFile;
2424
import com.magento.idea.magento2plugin.indexes.ModuleIndex;
2525
import com.magento.idea.magento2plugin.magento.packages.Package;
26+
import com.magento.idea.magento2plugin.project.Settings;
2627
import com.magento.idea.magento2plugin.stubs.indexes.ModuleNameIndex;
2728
import com.magento.idea.magento2plugin.util.CamelCaseToHyphen;
2829
import org.jetbrains.annotations.NotNull;
@@ -100,7 +101,7 @@ public NewModuleDialog(
100101
setModuleDependencies();
101102

102103
moduleLicenseCustom.setToolTipText("Custom License Name");
103-
moduleLicenseCustom.setText("proprietary");
104+
moduleLicenseCustom.setText(Settings.getDefaultLicenseName(project));
104105

105106
buttonOK.addActionListener(new ActionListener() {
106107
public void actionPerformed(ActionEvent e) {

src/com/magento/idea/magento2plugin/project/Settings.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
)
1919
public class Settings implements PersistentStateComponent<Settings> {
2020
public boolean pluginEnabled = false;
21+
public String defaultLicenseName = "Proprietary";
2122

2223
@Nullable
2324
@Override
@@ -37,4 +38,8 @@ public static Settings getInstance(Project project) {
3738
public static boolean isEnabled(@NotNull Project project) {
3839
return getInstance(project).pluginEnabled;
3940
}
41+
42+
public static String getDefaultLicenseName(@NotNull Project project) {
43+
return getInstance(project).defaultLicenseName;
44+
}
4045
}

src/com/magento/idea/magento2plugin/project/SettingsForm.form

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!--
3-
/**
4-
* Copyright © Magento, Inc. All rights reserved.
5-
* See COPYING.txt for license details.
6-
*/
7-
-->
82
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.magento.idea.magento2plugin.project.SettingsForm">
93
<grid id="27dc6" binding="panel1" default-binding="true" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
104
<margin top="0" left="0" bottom="0" right="0"/>
@@ -20,9 +14,13 @@
2014
<rowspec value="center:max(d;4px):noGrow"/>
2115
<rowspec value="top:3dlu:noGrow"/>
2216
<rowspec value="center:max(d;4px):noGrow"/>
17+
<rowspec value="top:3dlu:noGrow"/>
18+
<rowspec value="center:max(d;4px):noGrow"/>
2319
<colspec value="fill:max(d;4px):noGrow"/>
2420
<colspec value="left:4dlu:noGrow"/>
2521
<colspec value="fill:max(d;4px):noGrow"/>
22+
<colspec value="left:4dlu:noGrow"/>
23+
<colspec value="fill:d:grow"/>
2624
<constraints>
2725
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
2826
</constraints>
@@ -57,6 +55,27 @@
5755
<text value=""/>
5856
</properties>
5957
</component>
58+
<component id="7bde6" class="javax.swing.JLabel">
59+
<constraints>
60+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
61+
<forms/>
62+
</constraints>
63+
<properties>
64+
<text value="Module Default License Name"/>
65+
</properties>
66+
</component>
67+
<component id="87330" class="javax.swing.JTextField" binding="moduleDefaultLicenseName">
68+
<constraints>
69+
<grid row="6" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
70+
<preferred-size width="150" height="-1"/>
71+
</grid>
72+
<forms defaultalign-horz="false"/>
73+
</constraints>
74+
<properties>
75+
<maximumSize width="150" height="40"/>
76+
<toolTipText value="Custom License Name"/>
77+
</properties>
78+
</component>
6079
</children>
6180
</grid>
6281
<component id="2ef99" class="javax.swing.JCheckBox" binding="pluginEnabled">

src/com/magento/idea/magento2plugin/project/SettingsForm.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public class SettingsForm implements Configurable {
4141
private JPanel panel1;
4242
private JButton regenerateUrnMapButton;
4343
private JLabel magentoVersion;
44+
private JTextField moduleDefaultLicenseName;
4445
private MagentoVersion magentoVersionModel = MagentoVersion.getInstance();
4546

4647
public SettingsForm(@NotNull final Project project) {
@@ -84,6 +85,8 @@ public void mouseClicked(MouseEvent e) {
8485
magentoVersion.setText("Magento version: " . concat(version));
8586
}
8687

88+
moduleDefaultLicenseName.setText(getSettings().defaultLicenseName);
89+
8790
return (JComponent) panel1;
8891
}
8992

@@ -94,12 +97,16 @@ private void reindex() {
9497

9598
@Override
9699
public boolean isModified() {
97-
return !pluginEnabled.isSelected() == getSettings().pluginEnabled;
100+
boolean licenseChanged = !moduleDefaultLicenseName.getText().equals(getSettings().defaultLicenseName);
101+
boolean statusChanged = !pluginEnabled.isSelected() == getSettings().pluginEnabled;
102+
103+
return statusChanged || licenseChanged;
98104
}
99105

100106
@Override
101107
public void apply() throws ConfigurationException {
102108
getSettings().pluginEnabled = pluginEnabled.isSelected();
109+
getSettings().defaultLicenseName = moduleDefaultLicenseName.getText();
103110
buttonReindex.setEnabled(getSettings().pluginEnabled);
104111
regenerateUrnMapButton.setEnabled(getSettings().pluginEnabled);
105112

0 commit comments

Comments
 (0)