Skip to content

Commit ed7b1a9

Browse files
author
Vitaliy Boyko
committed
445: Covered the NoninterceptableInterface case by plugin inspection and updated create a plugin action
1 parent 1eef554 commit ed7b1a9

File tree

15 files changed

+524
-209
lines changed

15 files changed

+524
-209
lines changed

Diff for: CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
66

77
## 3.0.4
88

9+
### Fixed
10+
11+
- Overriding the interface generates invalid php code
12+
- Overriding a template from the base area
13+
- Disabled an ability to create a plugin for a class that implements `NoninterceptableInterface`
14+
15+
### Added
16+
17+
- `NoninterceptableInterface` case warning to the plugin inspection
18+
919
## 3.0.3
1020

1121
### Fixed

Diff for: resources/magento2/inspection.properties

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ inspection.graphql.resolver.fix.title=Select one of the following interface
88
inspection.graphql.schema.resolver.fix.family=Create GraphQL Resolver
99
inspection.plugin.error.nonPublicMethod=You can't declare a plugin for a not public method.
1010
inspection.plugin.error.finalClass=You can't declare a plugin for a final class.
11+
inspection.plugin.error.noninterceptableInterface=You can't declare a plugin for a class implements Magento\\Framework\\ObjectManager\\NoninterceptableInterface.
1112
inspection.plugin.error.finalMethod=You can't declare a plugin for a final method.
1213
inspection.plugin.error.staticMethod=You can't declare a plugin for a static method.
1314
inspection.plugin.error.constructMethod=You can't declare a plugin for a __construct method.

Diff for: src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
import com.jetbrains.php.lang.psi.elements.PhpClass;
1919
import com.magento.idea.magento2plugin.MagentoIcons;
2020
import com.magento.idea.magento2plugin.actions.generation.dialog.CreateAPluginDialog;
21+
import com.magento.idea.magento2plugin.inspections.php.util.PhpClassImplementsNoninterceptableInterfaceUtil;
2122
import com.magento.idea.magento2plugin.project.Settings;
2223
import com.magento.idea.magento2plugin.util.GetFirstClassOfFile;
23-
import com.magento.idea.magento2plugin.util.magento.plugin.IsPluginAllowedForMethod;
24+
import com.magento.idea.magento2plugin.util.magento.plugin.IsPluginAllowedForMethodUtil;
2425
import org.jetbrains.annotations.NotNull;
2526

2627
public class CreateAPluginAction extends DumbAwareAction {
2728
public static final String ACTION_NAME = "Create a new Plugin for this method";
2829
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Plugin";
29-
private final IsPluginAllowedForMethod isPluginAllowed;// NOPMD
3030
private final GetFirstClassOfFile getFirstClassOfFile;
3131
private Method targetMethod;
3232
private PhpClass targetClass;
@@ -36,7 +36,6 @@ public class CreateAPluginAction extends DumbAwareAction {
3636
*/
3737
public CreateAPluginAction() {
3838
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
39-
this.isPluginAllowed = IsPluginAllowedForMethod.getInstance();
4039
this.getFirstClassOfFile = GetFirstClassOfFile.getInstance();
4140
}
4241

@@ -55,6 +54,7 @@ public void update(final AnActionEvent event) {
5554
if (phpClass == null
5655
|| !(psiFile instanceof PhpFile)
5756
|| phpClass.isFinal()
57+
|| PhpClassImplementsNoninterceptableInterfaceUtil.execute(phpClass)
5858
|| this.targetMethod == null
5959
) {
6060
this.setStatus(event, false);
@@ -110,13 +110,13 @@ private void fetchTargetMethod(
110110
return;
111111
}
112112
if (element instanceof Method && element.getParent()
113-
== phpClass && isPluginAllowed.check((Method) element)) {
113+
== phpClass && IsPluginAllowedForMethodUtil.check((Method) element)) {
114114
this.targetMethod = (Method) element;
115115
return;
116116
}
117117
final PsiElement parent = element.getParent();
118118
if (parent instanceof Method && parent.getParent()
119-
== phpClass && isPluginAllowed.check((Method) parent)) {
119+
== phpClass && IsPluginAllowedForMethodUtil.check((Method) parent)) {
120120
this.targetMethod = (Method) parent;
121121
}
122122
}

0 commit comments

Comments
 (0)