Skip to content

Commit c8d2559

Browse files
Merge pull request #969 from doninAtwix/965-generation-acl-xml
965: Added a new context dependent Action for the acl.xml file generation
2 parents b21e978 + 1ac2b76 commit c8d2559

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

resources/META-INF/plugin.xml

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<action id="MagentoCreateRoutesFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewRoutesXmlAction"/>
6363
<action id="MagentoCreateDiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewDiXmlAction"/>
6464
<action id="MagentoCreateWebapiFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewWebapiXmlAction"/>
65+
<action id="MagentoCreateAclFile" class="com.magento.idea.magento2plugin.actions.context.xml.NewAclXmlAction"/>
6566
<!-- Context dependent actions -->
6667
<separator/>
6768
<add-to-group group-id="NewGroup" anchor="before" relative-to-action="NewXml"/>
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0"?>
22
#parse("XML File Header.xml")
3-
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
3+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
45
</config>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
package com.magento.idea.magento2plugin.actions.context.xml;
7+
8+
import com.intellij.ide.fileTemplates.actions.AttributesDefaults;
9+
import com.intellij.psi.PsiDirectory;
10+
import com.intellij.psi.PsiFile;
11+
import com.magento.idea.magento2plugin.actions.context.AbstractContextAction;
12+
import com.magento.idea.magento2plugin.magento.files.ModuleAclXml;
13+
import com.magento.idea.magento2plugin.magento.packages.ComponentType;
14+
import com.magento.idea.magento2plugin.magento.packages.Package;
15+
import com.magento.idea.magento2plugin.util.magento.GetMagentoModuleUtil;
16+
import org.jetbrains.annotations.NotNull;
17+
18+
public class NewAclXmlAction extends AbstractContextAction {
19+
20+
public static final String ACTION_NAME = "Magento 2 ACL File";
21+
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 acl.xml file";
22+
23+
/**
24+
* New acl.xml file generation action constructor.
25+
*/
26+
public NewAclXmlAction() {
27+
super(ACTION_NAME, ACTION_DESCRIPTION, ModuleAclXml.getInstance());
28+
}
29+
30+
@Override
31+
protected boolean isVisible(
32+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
33+
final @NotNull PsiDirectory targetDirectory,
34+
final PsiFile targetFile
35+
) {
36+
return targetDirectory.getName().equals(Package.moduleBaseAreaDir)
37+
&& moduleData.getType().equals(ComponentType.module);
38+
}
39+
40+
@Override
41+
protected AttributesDefaults getProperties(
42+
final @NotNull AttributesDefaults defaults,
43+
final @NotNull GetMagentoModuleUtil.MagentoModuleData moduleData,
44+
final PsiDirectory targetDirectory,
45+
final PsiFile targetFile
46+
) {
47+
return defaults;
48+
}
49+
}

0 commit comments

Comments
 (0)