Skip to content

Commit 851c8c5

Browse files
author
SilinMykola
committed
1094 fix a new layout action error
1 parent 82829a5 commit 851c8c5

File tree

2 files changed

+5
-45
lines changed

2 files changed

+5
-45
lines changed

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

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static void open(
122122
* Fire generation process if all fields are valid.
123123
*/
124124
private void onOK() {
125-
if (validateFormFields() && isUnderscoreCorrect()) {
125+
if (validateFormFields()) {
126126
final String[] layoutNameParts = getLayoutNameParts();
127127
new LayoutXmlTemplateGenerator(
128128
new LayoutXmlData(
@@ -188,51 +188,11 @@ private String[] getLayoutNameParts() {
188188
actionName = layoutNameParts[2];
189189
}
190190

191-
return new String[]{routeName, controllerName, actionName};
192-
}
193-
194-
/**
195-
* Check is count of underscore is correct in layout name.
196-
*
197-
* @return boolean
198-
*/
199-
private boolean isUnderscoreCorrect() {
200-
final String name = layoutName.getText().trim();
201-
202-
if (name.contains("_")) {
203-
final int count = countUnderscore(name);
204-
205-
if (count != 0 && count != 2) {
206-
DialogFieldErrorUtil.showErrorMessageForField(
207-
layoutName,
208-
layoutNameErrorMessage,
209-
new ValidatorBundle()
210-
.message("validator.layoutNameUnderscoreQtyInvalid")
211-
);
212-
213-
return false;
214-
}
191+
if (layoutNameParts.length == 2 || layoutNameParts.length > 3) { // NOPMD
192+
routeName = layoutName.getText().trim();
215193
}
216194

217-
return true;
218-
}
219-
220-
/**
221-
* Count underscore symbols in string.
222-
*
223-
* @param name String
224-
* @return int
225-
*/
226-
private int countUnderscore(final String name) {
227-
int count = 0;
228-
229-
for (int i = 0; i < name.length(); i++) {
230-
if (name.charAt(i) == '_') { //NOPMD
231-
count++;
232-
}
233-
}
234-
235-
return count;
195+
return new String[]{routeName, controllerName, actionName};
236196
}
237197

238198
/**

src/com/magento/idea/magento2plugin/util/RegExUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class RegExUtil {
5050
= "(\\d+)\\.(\\d+)\\.(\\d+)[a-zA-Z0-9_\\-]*";
5151

5252
public static final String LAYOUT_NAME
53-
= "^([a-zA-Z0-9]+){1,}(_[a-zA-Z0-9]+){0,2}";
53+
= "^([a-zA-Z0-9]+){1}(_[a-zA-Z0-9]+){0,}";
5454

5555
public static class Magento {
5656

0 commit comments

Comments
 (0)