Skip to content

Commit a1c54d2

Browse files
Merge branch '4.0.0-develop' into only-viisible-fields-validation
2 parents c55976f + 0889543 commit a1c54d2

File tree

56 files changed

+1188
-50
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1188
-50
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
66

77
## 4.0.0
88

9+
## 3.2.1
10+
11+
### Fixed
12+
13+
- Directory validator
14+
- Entity data mapper file template
15+
916
## 3.2.0
1017

1118
### Added

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
plugins {
7-
id 'org.jetbrains.intellij' version '0.6.5'
7+
id 'org.jetbrains.intellij' version '0.7.2'
88
id 'checkstyle'
99
id 'pmd'
1010
id 'org.jetbrains.changelog' version '0.6.2'

gradle-tasks/checkstyle/checkstyle.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,8 @@
330330
</module>
331331
</module>
332332
<module name="SuppressWarningsFilter"/>
333+
<module name="RegexpHeader">
334+
<property name="header" value="^\/\*\n \* Copyright © Magento, Inc."/>
335+
<property name="fileExtensions" value="java"/>
336+
</module>
333337
</module>

resources/META-INF/plugin.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
<action id="OverrideInTheme.Menu" class="com.magento.idea.magento2plugin.actions.generation.OverrideInThemeAction">
9797
<add-to-group group-id="ProjectViewPopupMenu"/>
9898
</action>
99+
<action id="MagentoCreateAWebApiDeclaration.Menu" class="com.magento.idea.magento2plugin.actions.generation.NewWebApiDeclarationAction">
100+
<add-to-group group-id="EditorPopupMenu"/>
101+
</action>
99102

100103
<action id="CopyMagentoPath"
101104
class="com.magento.idea.magento2plugin.actions.CopyMagentoPath"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<route url="/V1/${ROUTE}" method="${METHOD}">
2+
<service class="${SERVICE}" method="${SERVICE_METHOD}"/>
3+
<resources>
4+
<resource ref="${RESOURCE}"/>
5+
</resources>
6+
</route>

resources/fileTemplates/code/Magento Web Api Declaration.xml.html

Whitespace-only changes.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0"?>
2+
<routes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Webapi:etc/webapi.xsd">
4+
</routes>

resources/fileTemplates/internal/Magento Web Api XML.xml.html

Whitespace-only changes.

resources/magento2/validation.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ validator.onlyNumbers=The {0} field must contain numbers only
1111
validator.mustNotBeNegative={0} must not be negative
1212
validator.identifier=The {0} field must contain letters, numbers, dashes, and underscores only
1313
validator.identifier.colon=The {0} field must contain letters, numbers, colons, dashes, and underscores only
14+
validator.identifier.forwardSlash=The {0} field must contain letters, numbers, dashes, forward slashes and underscores only
1415
validator.class.isNotValid=The {0} field does not contain a valid class name
1516
validator.fqn.isNotValid=The {0} field does not contain a valid fully qualified class name
1617
validator.class.shouldBeUnique=Duplicated class {0}
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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.openapi.actionSystem.AnAction;
9+
import com.intellij.openapi.actionSystem.AnActionEvent;
10+
import com.intellij.openapi.project.Project;
11+
import com.intellij.psi.PsiDirectory;
12+
import com.jetbrains.php.lang.psi.elements.Method;
13+
import com.jetbrains.php.lang.psi.elements.PhpClass;
14+
import com.magento.idea.magento2plugin.MagentoIcons;
15+
import com.magento.idea.magento2plugin.actions.generation.dialog.NewWebApiDeclarationDialog;
16+
import com.magento.idea.magento2plugin.magento.packages.MagentoPhpClass;
17+
import com.magento.idea.magento2plugin.project.Settings;
18+
import com.magento.idea.magento2plugin.util.php.PhpPsiElementsUtil;
19+
import org.jetbrains.annotations.NotNull;
20+
21+
public class NewWebApiDeclarationAction extends AnAction {
22+
23+
public static final String ACTION_NAME = "Create a new Web API declaration for this method";
24+
public static final String ACTION_DESCRIPTION =
25+
"Create a new Magento 2 Web API XML declaration";
26+
private Method currentPhpMethod;
27+
28+
/**
29+
* New WebApi declaration action constructor.
30+
*/
31+
public NewWebApiDeclarationAction() {
32+
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
33+
}
34+
35+
@Override
36+
public void update(final @NotNull AnActionEvent event) {
37+
setIsAvailableForEvent(event, false);
38+
final Project project = event.getProject();
39+
final Method method = PhpPsiElementsUtil.getPhpMethod(event);
40+
41+
if (project == null || !Settings.isEnabled(project) || method == null) {
42+
return;
43+
}
44+
45+
if (method.getContainingClass() == null) {
46+
return;
47+
}
48+
49+
if (!method.getAccess().isPublic()
50+
|| method.getName().equals(MagentoPhpClass.CONSTRUCT_METHOD_NAME)) {
51+
return;
52+
}
53+
54+
currentPhpMethod = method;
55+
setIsAvailableForEvent(event, true);
56+
}
57+
58+
@Override
59+
public void actionPerformed(final @NotNull AnActionEvent event) {
60+
final PsiDirectory directory =
61+
currentPhpMethod.getContainingFile().getContainingDirectory();
62+
63+
if (event.getProject() == null || directory == null) {
64+
return;
65+
}
66+
67+
final PhpClass phpClass = currentPhpMethod.getContainingClass();
68+
69+
if (phpClass == null) {
70+
return;
71+
}
72+
73+
final String classFqn = phpClass.getPresentableFQN();
74+
final String methodName = currentPhpMethod.getName();
75+
76+
NewWebApiDeclarationDialog.open(event.getProject(), directory, classFqn, methodName);
77+
}
78+
79+
/**
80+
* Set is action available for event.
81+
*
82+
* @param event AnActionEvent
83+
* @param isAvailable boolean
84+
*/
85+
private void setIsAvailableForEvent(
86+
final @NotNull AnActionEvent event,
87+
final boolean isAvailable
88+
) {
89+
event.getPresentation().setVisible(isAvailable);
90+
event.getPresentation().setEnabled(isAvailable);
91+
}
92+
}

0 commit comments

Comments
 (0)