Skip to content

Commit 02f8189

Browse files
authored
Merge pull request #1198 from bohdan-harniuk/merge-4.4.0-develop-into-4.4.1-develop
Merge 4.4.0 develop into 4.4.1 develop
2 parents 8cf8401 + 1b9eede commit 02f8189

File tree

10 files changed

+73
-10
lines changed

10 files changed

+73
-10
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
2424
- Code completion for `system.xml` and `config.xml` [#1077](https://github.com/magento/magento2-phpstorm-plugin/pull/1077)
2525
- Added easier navigation through plugins [#1121](https://github.com/magento/magento2-phpstorm-plugin/pull/1121)
2626
- Added inspection to check if type attr value in the virtual type tag attribute value exists [#1176](https://github.com/magento/magento2-phpstorm-plugin/pull/1176)
27+
- Added checks and detailed error messages during plugin activation [#1181](https://github.com/magento/magento2-phpstorm-plugin/pull/1181)
2728

2829
### Fixed
2930

31+
- Fixed NullPointerException at ObserverDeclarationInspection.java:188 [#1143](https://github.com/magento/magento2-phpstorm-plugin/issues/1143)
3032
- Fixed IncorrectOperationException: Rebind cannot be performed for class PolyVariantReferenceBase [#1173](https://github.com/magento/magento2-phpstorm-plugin/pull/1173)
3133
- Fixed create an observer for an event doesn't work through the context menu [#1166](https://github.com/magento/magento2-phpstorm-plugin/pull/1166)
3234
- Fixed IOException: Invalid file name at ReportBuilder [#1154](https://github.com/magento/magento2-phpstorm-plugin/pull/1154)

resources/META-INF/plugin.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
<separator/>
6161
<!-- Context dependent actions -->
6262
<action id="MagentoCreateAclFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewAclXmlAction"/>
63-
<action id="MagentoCreateGraphQlSchemaFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewGraphQLSchemaAction"/>
6463
<action id="MagentoCreateConfigFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewConfigXmlAction"/>
6564
<action id="MagentoCreateCrontabFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewCrontabXmlAction"/>
6665
<action id="MagentoCreateDiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewDiXmlAction"/>
@@ -91,7 +90,6 @@
9190
<action id="MagentoCreateACronjob" class="com.magento.idea.magento2plugin.actions.generation.NewCronjobAction" />
9291
<action id="MagentoCreateACronGroup" class="com.magento.idea.magento2plugin.actions.generation.NewCronGroupAction" />
9392
<action id="MagentoCreateAViewModel" class="com.magento.idea.magento2plugin.actions.generation.NewViewModelAction" />
94-
<action id="MagentoCreateAGraphQlResolver" class="com.magento.idea.magento2plugin.actions.generation.NewGraphQlResolverAction" />
9593
<action id="MagentoCreateCLICommand" class="com.magento.idea.magento2plugin.actions.generation.NewCLICommandAction" />
9694
<action id="MagentoCreateEmailTemplate" class="com.magento.idea.magento2plugin.actions.generation.NewEmailTemplateAction" />
9795
<action id="MagentoCreateUiComponentGrid" class="com.magento.idea.magento2plugin.actions.generation.NewUiComponentGridAction" />
@@ -621,7 +619,6 @@
621619
<internalFileTemplate name="Magento Regular Class"/>
622620
<internalFileTemplate name="Magento Observer Class"/>
623621
<internalFileTemplate name="Magento Events XML"/>
624-
<internalFileTemplate name="Magento GraphQL Resolver Class"/>
625622
<internalFileTemplate name="Magento Cron Job Class"/>
626623
<internalFileTemplate name="Magento Cron Tab XML"/>
627624
<internalFileTemplate name="Magento CLI Command Class"/>
@@ -635,7 +632,6 @@
635632
<internalFileTemplate name="Magento Routes XML"/>
636633
<internalFileTemplate name="Magento Layout XML"/>
637634
<internalFileTemplate name="Magento ACL XML"/>
638-
<internalFileTemplate name="Magento GraphQL Schema"/>
639635
<internalFileTemplate name="Magento Collection Class"/>
640636
<internalFileTemplate name="Magento Model Class"/>
641637
<internalFileTemplate name="Magento Resource Model Class"/>

resources/META-INF/withJsGraphQl.xml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
-->
77

88
<idea-plugin>
9+
<actions>
10+
<group id="GraphQL.MagentoContextBasedActionsGroup">
11+
<add-to-group group-id="MagentoContextBasedActionsGroup" anchor="last"/>
12+
<action id="MagentoCreateGraphQlSchemaFile"
13+
class="com.magento.idea.magento2plugin.actions.context.xml.NewGraphQLSchemaAction"/>
14+
</group>
15+
<group id="GraphQL.MagentoNewModuleFileGroup"
16+
text="GraphQL"
17+
popup="false">
18+
<add-to-group group-id="MagentoNewModuleFileGroup" anchor="last"/>
19+
<action id="MagentoCreateAGraphQlResolver" class="com.magento.idea.magento2plugin.actions.generation.NewGraphQlResolverAction" />
20+
</group>
21+
</actions>
922
<extensions defaultExtensionNs="com.intellij">
1023
<fileBasedIndex implementation="com.magento.idea.magento2plugin.stubs.indexes.graphql.GraphQlResolverIndex" />
1124
<codeInsight.lineMarkerProvider language="PHP" implementationClass="com.magento.idea.magento2plugin.linemarker.php.GraphQlResolverUsageLineMarkerProvider"/>
@@ -22,5 +35,8 @@
2235
enabledByDefault="true"
2336
level="ERROR"
2437
implementationClass="com.magento.idea.magento2plugin.inspections.graphqls.SchemaResolverInspection"/>
38+
39+
<internalFileTemplate name="Magento GraphQL Resolver Class"/>
40+
<internalFileTemplate name="Magento GraphQL Schema"/>
2541
</extensions>
2642
</idea-plugin>

resources/fileTemplates/internal/Magento Customer Eav Attribute Data Patch Class.php.ft

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class ${CLASS_NAME} implements ${IMPLEMENTS}
7777
$eavSetup->addAttributeToSet(
7878
${CUSTOMER_METADATA_INTERFACE}::ENTITY_TYPE_CUSTOMER,
7979
${CUSTOMER_METADATA_INTERFACE}::ATTRIBUTE_SET_ID_CUSTOMER,
80-
null,
80+
'Default',
8181
'${ATTRIBUTE_CODE}'
8282
);
8383

resources/magento2/validation.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
validator.notEmpty=The {0} field must not be empty
22
validator.box.notEmpty=The {0} field must contain a valid selection from the dropdown
33
validator.package.validPath=Please specify a valid Magento 2 installation path
4+
validator.package.validPathComposerFiles=File composer.json is missing in the current Magento 2 installation path
5+
validator.package.validPathVendor=Vendor dir is corrupt or missing in the current Magento 2 installation path
46
validator.properties.notEmpty=The properties must not be empty
57
validator.alphaNumericCharacters=The {0} field must contain letters and numbers only
68
validator.alphaNumericAndUnderscoreCharacters={0} must contain letters, numbers and underscores only

src/com/magento/idea/magento2plugin/inspections/xml/ObserverDeclarationInspection.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.intellij.codeInspection.ProblemHighlightType;
99
import com.intellij.codeInspection.ProblemsHolder;
1010
import com.intellij.ide.highlighter.XmlFileType;
11+
import com.intellij.openapi.externalSystem.service.execution.NotSupportedException;
1112
import com.intellij.openapi.vfs.VfsUtil;
1213
import com.intellij.openapi.vfs.VirtualFile;
1314
import com.intellij.psi.PsiElement;
@@ -71,6 +72,10 @@ public void visitFile(final @NotNull PsiFile file) {
7172
return;
7273
}
7374

75+
// This added to cover case if file exists only in memory.
76+
if (file.getContainingDirectory() == null) {
77+
return;
78+
}
7479
final EventIndex eventIndex = new EventIndex(file.getProject());
7580
final HashMap<String, XmlTag> targetObserversHash = new HashMap<>();
7681

@@ -108,7 +113,8 @@ public void visitFile(final @NotNull PsiFile file) {
108113
}
109114

110115
final String observerName = observerNameAttribute.getValue();
111-
if (observerName == null) {
116+
if (observerName == null
117+
|| observerNameAttribute.getValueElement() == null) {
112118
continue;
113119
}
114120

@@ -188,6 +194,11 @@ private List<HashMap<String, String>> fetchModuleNamesWhereSameObserverNameUsed(
188194
final EventIndex eventIndex,
189195
final PsiFile file
190196
) {
197+
if (file.getContainingDirectory() == null) {
198+
throw new NotSupportedException(
199+
"Operation is not supported for files in memory"
200+
);
201+
}
191202
final List<HashMap<String, String>> modulesName = new ArrayList<>();
192203
final String currentFileDirectory = file.getContainingDirectory().toString();
193204
final String currentFileFullPath = currentFileDirectory

src/com/magento/idea/magento2plugin/lang/php/MagentoProxyDeclarationFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private <E extends PhpNamedElement> boolean isValidFqn(final E candidate) {
5858
PhpClass targetClass = null;
5959

6060
if (candidate instanceof Method) {
61-
targetClass = (PhpClass) candidate.getParent();
61+
targetClass = ((Method) candidate).getContainingClass();
6262
} else if (candidate instanceof PhpClass) {
6363
targetClass = (PhpClass) candidate;
6464
}

src/com/magento/idea/magento2plugin/project/validator/SettingsFormValidator.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,30 @@ public SettingsFormValidator(
2828
*
2929
* @throws ConfigurationException Exception
3030
*/
31+
@SuppressWarnings({"PMD.CyclomaticComplexity", "PMD.AvoidDeeplyNestedIfStmts"})
3132
public void validate() throws ConfigurationException {
3233
if (form.isBeingUsed()) {
33-
if (!MagentoBasePathUtil.isMagentoFolderValid(form.getMagentoPath())) {
34+
final String magentoRootPath = form.getMagentoPath();
35+
final boolean isMagentoFrameworkDirExist =
36+
MagentoBasePathUtil.isMagentoFolderValid(magentoRootPath);
37+
38+
if (!MagentoBasePathUtil.isComposerJsonExists(magentoRootPath)) {
39+
if (isMagentoFrameworkDirExist) {
40+
throw new ConfigurationException(
41+
validatorBundle.message("validator.package.validPathComposerFiles")
42+
);
43+
}
3444
throw new ConfigurationException(
3545
validatorBundle.message("validator.package.validPath")
3646
);
3747
}
3848

49+
if (!isMagentoFrameworkDirExist) {
50+
throw new ConfigurationException(
51+
validatorBundle.message("validator.package.validPathVendor")
52+
);
53+
}
54+
3955
final String magentoVersion = form.getMagentoVersion();
4056
if (magentoVersion.length() == 0) {
4157
throw new ConfigurationException(

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.intellij.openapi.vfs.LocalFileSystem;
1010
import com.intellij.openapi.vfs.VfsUtil;
1111
import com.intellij.openapi.vfs.VirtualFile;
12+
import com.magento.idea.magento2plugin.magento.files.ComposerJson;
1213
import com.magento.idea.magento2plugin.magento.packages.Package;
1314
import java.util.Arrays;
1415
import org.jetbrains.annotations.NotNull;
@@ -18,7 +19,7 @@ public final class MagentoBasePathUtil {
1819
private MagentoBasePathUtil() {}
1920

2021
/**
21-
* Method detects Magento Framework Root.
22+
* Method detects Magento Framework Root (check if magento framework exists).
2223
*
2324
* @param path String
2425
* @return boolean
@@ -42,6 +43,25 @@ public static boolean isMagentoFolderValid(final String path) {
4243
return false;
4344
}
4445

46+
/**
47+
* Check if composer.json exists in directory.
48+
*
49+
* @param path String
50+
* @return boolean
51+
*/
52+
public static Boolean isComposerJsonExists(final String path) {
53+
if (StringUtil.isEmptyOrSpaces(path)) {
54+
return false;
55+
}
56+
final VirtualFile magentoRoot = LocalFileSystem.getInstance().findFileByPath(path);
57+
58+
if (magentoRoot == null || !magentoRoot.isDirectory()) {
59+
return false;
60+
}
61+
62+
return magentoRoot.findChild(ComposerJson.FILE_NAME) != null;
63+
}
64+
4565
/**
4666
* Check if specified path belongs to the correct vendor name.
4767
*

testData/actions/generation/generator/CustomerAttributeSetupPatchGenerator/generateMultiselectAttributeDataPatch/AddMultiselectTestCustomerAttribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function apply()
9696
$eavSetup->addAttributeToSet(
9797
CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER,
9898
CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
99-
null,
99+
'Default',
100100
'multiselect_test'
101101
);
102102

0 commit comments

Comments
 (0)