Skip to content

Commit 5cb91f1

Browse files
author
Vitaliy
authored
Merge branch '1.0.1-develop' into module-xml-registration-php-inspections
2 parents 3304780 + d03cab6 commit 5cb91f1

File tree

19 files changed

+1553
-0
lines changed

19 files changed

+1553
-0
lines changed

resources/META-INF/plugin.xml

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
6060
<action id="MagentoCreateAController" class="com.magento.idea.magento2plugin.actions.generation.NewControllerAction" />
6161
<action id="MagentoCreateACronjob" class="com.magento.idea.magento2plugin.actions.generation.NewCronjobAction" />
62+
<action id="MagentoCreateACronGroup" class="com.magento.idea.magento2plugin.actions.generation.NewCronGroupAction" />
6263
<action id="MagentoCreateAViewModel" class="com.magento.idea.magento2plugin.actions.generation.NewViewModelAction" />
6364
<action id="MagentoCreateAGraphQlResolver" class="com.magento.idea.magento2plugin.actions.generation.NewGraphQlResolverAction" />
6465
<action id="MagentoCreateCLICommand" class="com.magento.idea.magento2plugin.actions.generation.NewCLICommandAction" />
@@ -181,6 +182,7 @@
181182
<internalFileTemplate name="Magento CLI Command"/>
182183
<internalFileTemplate name="Magento Module Controller Backend Class"/>
183184
<internalFileTemplate name="Magento Module Controller Frontend Class"/>
185+
<internalFileTemplate name="Magento Module Cron Groups Xml"/>
184186
</extensions>
185187

186188
<extensions defaultExtensionNs="com.jetbrains.php">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<group id="${GROUP_NAME}">
2+
#if (${SCHEDULE_GENERATE_EVERY})<schedule_generate_every>${SCHEDULE_GENERATE_EVERY}</schedule_generate_every>#end
3+
#if (${SCHEDULE_AHEAD_FOR})<schedule_ahead_for>${SCHEDULE_AHEAD_FOR}</schedule_ahead_for>#end
4+
#if (${SCHEDULE_LIFETIME})<schedule_lifetime>${SCHEDULE_LIFETIME}</schedule_lifetime>#end
5+
#if (${HISTORY_CLEANUP_EVERY})<history_cleanup_every>${HISTORY_CLEANUP_EVERY}</history_cleanup_every>#end
6+
#if (${HISTORY_SUCCESS_LIFETIME})<history_success_lifetime>${HISTORY_SUCCESS_LIFETIME}</history_success_lifetime>#end
7+
#if (${HISTORY_FAILURE_LIFETIME})<history_failure_lifetime>${HISTORY_FAILURE_LIFETIME}</history_failure_lifetime>#end
8+
#if (${USE_SEPARATE_PROCESS})<use_separate_process>${USE_SEPARATE_PROCESS}</use_separate_process>#end
9+
</group>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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">Each CRON group should be registered in cron_groups.xml in order to group CRON jobs with specific CRON group properties.</font>
13+
</td>
14+
</tr>
15+
<tr>
16+
<td>
17+
<font face="verdana" size="-1">
18+
<a href="https://devdocs.magento.com/guides/v2.3/config-guide/cron/custom-cron-tut.html">Configure a custom cron job and cron group (tutorial)</a>
19+
</font>
20+
</td>
21+
</tr>
22+
<tr>
23+
<td>
24+
<font face="verdana" size="-1">
25+
<a href="https://devdocs.magento.com/guides/v2.3/config-guide/cron/custom-cron-ref.html#specify-cron-group-options">Specifying Cron group options</a>
26+
</font>
27+
</td>
28+
</tr>
29+
</table>
30+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
31+
<tr>
32+
<td colspan="3"><font face="verdana" size="-1">Predefined variables explanation:</font></td>
33+
</tr>
34+
<tr>
35+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${GROUP_NAME}</b></font></nobr></td>
36+
<td width="10">&nbsp;</td>
37+
<td width="100%" valign="top"><font face="verdana" size="-1">A cron group name.</font></td>
38+
</tr>
39+
<tr>
40+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SCHEDULE_GENERATE_EVERY}</b></font></nobr></td>
41+
<td width="10">&nbsp;</td>
42+
<td width="100%" valign="top"><font face="verdana" size="-1">Frequency (in minutes) that schedules are written to the cron_schedule table.</font></td>
43+
</tr>
44+
<tr>
45+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SCHEDULE_AHEAD_FOR}</b></font></nobr></td>
46+
<td width="10">&nbsp;</td>
47+
<td width="100%" valign="top"><font face="verdana" size="-1">Time (in minutes) in advance that schedules are written to the cron_schedule table.</font></td>
48+
</tr>
49+
<tr>
50+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${SCHEDULE_LIFETIME}</b></font></nobr></td>
51+
<td width="10">&nbsp;</td>
52+
<td width="100%" valign="top"><font face="verdana" size="-1">Window of time (in minutes) that cron job must start or will be considered missed (“too late” to run).</font></td>
53+
</tr>
54+
<tr>
55+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${HISTORY_CLEANUP_EVERY}</b></font></nobr></td>
56+
<td width="10">&nbsp;</td>
57+
<td width="100%" valign="top"><font face="verdana" size="-1">Time (in minutes) that cron history is kept in the database.</font></td>
58+
</tr>
59+
<tr>
60+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${HISTORY_SUCCESS_LIFETIME}</b></font></nobr></td>
61+
<td width="10">&nbsp;</td>
62+
<td width="100%" valign="top"><font face="verdana" size="-1">Time (in minutes) that the record of successfully completed cron jobs are kept in the database.</font></td>
63+
</tr>
64+
<tr>
65+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${HISTORY_FAILURE_LIFETIME}</b></font></nobr></td>
66+
<td width="10">&nbsp;</td>
67+
<td width="100%" valign="top"><font face="verdana" size="-1">Time (in minutes) that the record of failed cron jobs are kept in the database.</font></td>
68+
</tr>
69+
<tr>
70+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${USE_SEPARATE_PROCESS}</b></font></nobr></td>
71+
<td width="10">&nbsp;</td>
72+
<td width="100%" valign="top"><font face="verdana" size="-1">Run this crongroup’s jobs in a separate php process</font></td>
73+
</tr>
74+
</table>
75+
</body>
76+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/cron_groups.xsd">
3+
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
cron_groups.xml file is the place where cron groups are declared.
12+
</p>
13+
<p>
14+
Read more about <a href="https://devdocs.magento.com/guides/v2.3/config-guide/cron/custom-cron-ref.html">Custom cron job and cron group reference</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">cron_groups.xml should be defined in the global area</font></td>
21+
</tr>
22+
</table>
23+
</body>
24+
</html>

resources/magento2/common.properties

+13
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ common.controller.inheritAction=Inherit Action Class
1010
common.controller.backend.acl=Admin Resource ACL
1111
common.controller.action=Controller Action
1212
common.ok=OK
13+
common.yes=Yes
14+
common.no=No
15+
common.optionName=Option Name
16+
common.optionValue=Option Value
17+
common.optionAdd=Add Option
18+
common.optionDescription=Option Description
1319
common.cancel=Cancel
1420
common.error=Error
1521
common.module.target=Target Module
@@ -39,3 +45,10 @@ common.cli.generate.error=New CLI Command Generation Error
3945
common.cli.class.title=CLI Command Class
4046
common.validationErrorTitle=Validation Error
4147
common.defaultConsoleDirectory=Console
48+
common.cronGroup.description.scheduleGenerateEvery=Frequency (in minutes) that schedules are written to the cron_schedule table.
49+
common.cronGroup.description.scheduleAheadFor=Time (in minutes) in advance that schedules are written to the cron_schedule table.
50+
common.cronGroup.description.scheduleLifetime=Window of time (in minutes) that cron job must start or will be considered missed ("too late" to run).
51+
common.cronGroup.description.historyCleanupEvery=Time (in minutes) that cron history is kept in the database.
52+
common.cronGroup.description.historySuccessLifetime=Time (in minutes) that the record of successfully completed cron jobs are kept in the database.
53+
common.cronGroup.description.historyFailureLifetime=Time (in minutes) that the record of failed cron jobs are kept in the database.
54+
common.cronGroup.description.useSeparateProcess=Run this crongroup’s jobs in a separate php process.

resources/magento2/validation.properties

+4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
validator.notEmpty={0} must not be empty
22
validator.package.validPath=Please specify a valid Magento 2 installation path
33
validator.alphaNumericCharacters={0} must contain letters and numbers only
4+
validator.alreadyDeclared={0} is already declared in the {1} module.
45
validator.startWithNumberOrCapitalLetter={0} must start from a number or a capital letter
56
validator.onlyNumbers={0} must contain numbers only
7+
validator.mustNotBeNegative={0} must not be negative
68
validator.identifier={0} must contain letters, numbers, dashes, and underscores only
79
validator.class.isNotValid={0} is not valid class name
810
validator.namespace.isNotValid={0} is not valid namespace name
911
validator.directory.isNotValid={0} is not valid
1012
validator.module.noSuchModule=No such module {0}
1113
validator.file.alreadyExists={0} already exists
1214
validator.file.cantBeCreated={0} can't be created
15+
validator.file.isNotWritable=%s file is binary or has no document associations
16+
validator.file.noDocumentAssociations={0} file is binary or has no document associations
1317
validator.class.alreadyDeclared={0} already declared in the target module
1418
validator.magentoVersionInvalid=Please specify valid Magento version or use 'any' keyword as default
1519
validator.class.targetClassNotFound=Target class is not found. Check the di.xml file
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.AnActionEvent;
10+
import com.intellij.openapi.actionSystem.CommonDataKeys;
11+
import com.intellij.openapi.actionSystem.DataContext;
12+
import com.intellij.openapi.actionSystem.LangDataKeys;
13+
import com.intellij.openapi.project.Project;
14+
import com.intellij.psi.PsiDirectory;
15+
import com.magento.idea.magento2plugin.MagentoIcons;
16+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewCronGroupDialog;
17+
18+
@SuppressWarnings({"PMD.OnlyOneReturn"})
19+
public class NewCronGroupAction extends com.intellij.openapi.actionSystem.AnAction {
20+
public static final String ACTION_NAME = "Magento 2 Cron Group";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 cron group";
22+
23+
/**
24+
* New CRON group action constructor.
25+
*/
26+
public NewCronGroupAction() {
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+
46+
if (directory == null) {
47+
return;
48+
}
49+
50+
NewCronGroupDialog.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,135 @@
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 CronGroupXmlData {
10+
private final String module;
11+
private final String groupName;
12+
private final Integer scheduleGenerateEvery;
13+
private final Integer scheduleAheadFor;
14+
private final Integer scheduleLifetime;
15+
private final Integer historyCleanupEvery;
16+
private final Integer historySuccessLifetime;
17+
private final Integer historyFailureLifetime;
18+
private final Integer useSeparateProcess;
19+
20+
/**
21+
* Cron group XML data constructor.
22+
*
23+
* @param module Module name
24+
* @param groupName CRON group name
25+
* @param scheduleGenerateEvery Schedule generate every
26+
* @param scheduleAheadFor Schedule ahead for
27+
* @param scheduleLifetime Schedule lifetime
28+
* @param historyCleanupEvery History cleanup every
29+
* @param historySuccessLifetime History success lifetime
30+
* @param historyFailureLifetime History failure lifetime
31+
* @param useSeparateProcess Use separate process
32+
*/
33+
public CronGroupXmlData(
34+
final String module,
35+
final String groupName,
36+
final Integer scheduleGenerateEvery,
37+
final Integer scheduleAheadFor,
38+
final Integer scheduleLifetime,
39+
final Integer historyCleanupEvery,
40+
final Integer historySuccessLifetime,
41+
final Integer historyFailureLifetime,
42+
final Integer useSeparateProcess
43+
) {
44+
this.module = module;
45+
this.groupName = groupName;
46+
this.scheduleGenerateEvery = scheduleGenerateEvery;
47+
this.scheduleAheadFor = scheduleAheadFor;
48+
this.scheduleLifetime = scheduleLifetime;
49+
this.historyCleanupEvery = historyCleanupEvery;
50+
this.historySuccessLifetime = historySuccessLifetime;
51+
this.historyFailureLifetime = historyFailureLifetime;
52+
this.useSeparateProcess = useSeparateProcess;
53+
}
54+
55+
/**
56+
* Get module name.
57+
*
58+
* @return String
59+
*/
60+
public String getModule() {
61+
return module;
62+
}
63+
64+
/**
65+
* Get CRON group name.
66+
*
67+
* @return String
68+
*/
69+
public String getGroupName() {
70+
return groupName;
71+
}
72+
73+
/**
74+
* Get schedule ahead for.
75+
*
76+
* @return Integer
77+
*/
78+
public Integer getScheduleAheadFor() {
79+
return scheduleAheadFor;
80+
}
81+
82+
/**
83+
* Get schedule generate every.
84+
*
85+
* @return Integer
86+
*/
87+
public Integer getScheduleGenerateEvery() {
88+
return scheduleGenerateEvery;
89+
}
90+
91+
/**
92+
* Get schedule lifetime.
93+
*
94+
* @return Integer
95+
*/
96+
public Integer getScheduleLifetime() {
97+
return scheduleLifetime;
98+
}
99+
100+
/**
101+
* Get history cleanup every.
102+
*
103+
* @return Integer
104+
*/
105+
public Integer getHistoryCleanupEvery() {
106+
return historyCleanupEvery;
107+
}
108+
109+
/**
110+
* Get history success lifetime.
111+
*
112+
* @return Integer
113+
*/
114+
public Integer getHistorySuccessLifetime() {
115+
return historySuccessLifetime;
116+
}
117+
118+
/**
119+
* Get history failure lifetime.
120+
*
121+
* @return Integer
122+
*/
123+
public Integer getHistoryFailureLifetime() {
124+
return historyFailureLifetime;
125+
}
126+
127+
/**
128+
* Get use separate process.
129+
*
130+
* @return Integer
131+
*/
132+
public Integer getUseSeparateProcess() {
133+
return useSeparateProcess;
134+
}
135+
}

0 commit comments

Comments
 (0)