diff --git a/src/com/magento/idea/magento2plugin/actions/generation/data/ModuleXmlData.java b/src/com/magento/idea/magento2plugin/actions/generation/data/ModuleXmlData.java index fdab50588..d31528952 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/data/ModuleXmlData.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/data/ModuleXmlData.java @@ -6,6 +6,7 @@ package com.magento.idea.magento2plugin.actions.generation.data; import com.intellij.psi.PsiDirectory; +import java.util.List; @SuppressWarnings({"PMD.DataClass"}) public class ModuleXmlData { @@ -13,6 +14,7 @@ public class ModuleXmlData { private final String moduleName; private final String setupVersion; private final PsiDirectory baseDir; + private final List moduleSequences; private final boolean createModuleDirs; /** @@ -29,12 +31,14 @@ public ModuleXmlData( final String moduleName, final String setupVersion, final PsiDirectory baseDir, + final List moduleSequences, final boolean createModuleDirs ) { this.packageName = packageName; this.moduleName = moduleName; this.setupVersion = setupVersion; this.baseDir = baseDir; + this.moduleSequences = moduleSequences; this.createModuleDirs = createModuleDirs; } @@ -54,6 +58,10 @@ public String getSetupVersion() { return this.setupVersion; } + public List getModuleSequences() { + return moduleSequences; + } + public boolean isCreateModuleDirs() { return this.createModuleDirs; } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java index 99cf87247..4fdd1c4a1 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/dialog/NewModuleDialog.java @@ -213,6 +213,7 @@ private void generateModuleXml() { getModuleName(), getSetupVersion(), getBaseDir(), + getModuleDependencies(), true ), project).generate(NewModuleAction.actionName, true); } diff --git a/src/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGenerator.java b/src/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGenerator.java index d072796b3..8205a9cea 100644 --- a/src/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGenerator.java +++ b/src/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGenerator.java @@ -14,6 +14,7 @@ import com.magento.idea.magento2plugin.actions.generation.generator.util.FileFromTemplateGenerator; import com.magento.idea.magento2plugin.magento.files.ModuleXml; import com.magento.idea.magento2plugin.magento.packages.Package; +import java.util.List; import java.util.Properties; import org.jetbrains.annotations.NotNull; @@ -74,5 +75,30 @@ protected void fillAttributes(final Properties attributes) { if (moduleXmlData.getSetupVersion() != null) { attributes.setProperty("SETUP_VERSION", moduleXmlData.getSetupVersion()); } + + final String sequences = this.getSequencesString(moduleXmlData.getModuleSequences()); + if (!sequences.isEmpty()) { + attributes.setProperty( + "SEQUENCES", + sequences + ); + } + } + + private String getSequencesString(final List sequences) { + String result = ""; + final Object[] dependencies = sequences.toArray(); + final boolean noDependency = dependencies.length == 1 && dependencies[0] + .equals(ModuleXml.NO_SEQUENCES_LABEL); + + if (noDependency) { + return result; + } + + for (final Object o : dependencies) { + result = result.concat(String.format("", o.toString())); + } + + return result; } } diff --git a/src/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java b/src/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java index 141512e3c..b6c9d669b 100644 --- a/src/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java +++ b/src/com/magento/idea/magento2plugin/generation/php/MagentoModuleGenerator.java @@ -31,7 +31,6 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; - public class MagentoModuleGenerator extends WebProjectTemplate { public static String actionName = "Magento 2 Module"; @@ -133,7 +132,7 @@ private PsiFile generateComposerJson( * @param project Project * @param baseDir Base directory * @param settings Settings - * @return + * @return void */ private PsiFile generateRegistrationPhp( @NotNull final Project project, @@ -165,6 +164,7 @@ private void generateModuleXml( settings.getModuleName(), settings.getModuleVersion(), baseDir, + new ArrayList<>(), false ); final ModuleXmlGenerator moduleXmlGenerator = diff --git a/src/com/magento/idea/magento2plugin/magento/files/ModuleXml.java b/src/com/magento/idea/magento2plugin/magento/files/ModuleXml.java index 7cbd98fd1..916b39181 100644 --- a/src/com/magento/idea/magento2plugin/magento/files/ModuleXml.java +++ b/src/com/magento/idea/magento2plugin/magento/files/ModuleXml.java @@ -12,6 +12,7 @@ public class ModuleXml implements ModuleFileInterface { public static final String FILE_NAME = "module.xml"; public static final String MODULE_ATTR_NAME = "name"; public static final String TEMPLATE = "Magento Module XML"; + public static final String NO_SEQUENCES_LABEL = "None"; private static final ModuleXml INSTANCE = new ModuleXml(); /** diff --git a/testData/actions/generation/generator/ModuleXmlGenerator/generateFileInRoot/module.xml b/testData/actions/generation/generator/ModuleXmlGenerator/generateFileInRoot/module.xml index 1bb7ffdf1..9a3a1c6e4 100644 --- a/testData/actions/generation/generator/ModuleXmlGenerator/generateFileInRoot/module.xml +++ b/testData/actions/generation/generator/ModuleXmlGenerator/generateFileInRoot/module.xml @@ -1,5 +1,10 @@ - + + + + + + diff --git a/testData/actions/generation/generator/ModuleXmlGenerator/generateModuleFile/module.xml b/testData/actions/generation/generator/ModuleXmlGenerator/generateModuleFile/module.xml index 1bb7ffdf1..9a3a1c6e4 100644 --- a/testData/actions/generation/generator/ModuleXmlGenerator/generateModuleFile/module.xml +++ b/testData/actions/generation/generator/ModuleXmlGenerator/generateModuleFile/module.xml @@ -1,5 +1,10 @@ - + + + + + + diff --git a/testData/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersion/generateModuleFile/module.xml b/testData/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersion/generateModuleFile/module.xml index 9a16123f5..abb1815af 100644 --- a/testData/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersion/generateModuleFile/module.xml +++ b/testData/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersion/generateModuleFile/module.xml @@ -1,5 +1,10 @@ - + + + + + + diff --git a/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersionTest.java b/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersionTest.java index 04332ca2b..4a0fc2498 100644 --- a/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersionTest.java +++ b/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorHaveSetupVersionTest.java @@ -7,6 +7,7 @@ import com.magento.idea.magento2plugin.magento.files.ModuleXml; import com.magento.idea.magento2plugin.magento.packages.File; import com.magento.idea.magento2plugin.magento.packages.Package; +import java.util.Arrays; public class ModuleXmlGeneratorHaveSetupVersionTest extends BaseGeneratorTestCase { @@ -24,6 +25,7 @@ public void testGenerateModuleFile() { "Module1", "1.0.0", projectDir, + Arrays.asList("Magento_Catalog", "Magento_InventoryApi"), true ); final ModuleXmlGenerator moduleXmlGenerator = new ModuleXmlGenerator( diff --git a/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorTest.java b/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorTest.java index b22397690..bd81f169a 100644 --- a/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorTest.java +++ b/tests/com/magento/idea/magento2plugin/actions/generation/generator/ModuleXmlGeneratorTest.java @@ -12,6 +12,7 @@ import com.magento.idea.magento2plugin.magento.files.ModuleXml; import com.magento.idea.magento2plugin.magento.packages.File; import com.magento.idea.magento2plugin.magento.packages.Package; +import java.util.Arrays; public class ModuleXmlGeneratorTest extends BaseGeneratorTestCase { @@ -29,6 +30,7 @@ public void testGenerateModuleFile() { "Module", null, projectDir, + Arrays.asList("Magento_Catalog", "Magento_InventoryApi"), true ); final ModuleXmlGenerator moduleXmlGenerator = new ModuleXmlGenerator( @@ -60,6 +62,7 @@ public void testGenerateFileInRoot() { "Module", null, projectDir, + Arrays.asList("Magento_Catalog", "Magento_InventoryApi"), false ); final ModuleXmlGenerator moduleXmlGenerator = new ModuleXmlGenerator(