Skip to content

Commit 4767c2c

Browse files
committed
feat: generator for sample config.xml file
1 parent 27dee04 commit 4767c2c

File tree

5 files changed

+44
-0
lines changed

5 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1818
- Added: Generator command for sample widget.xml file
1919
- Added: Generator command for sample extension_attributes.xml file
2020
- Added: Generator command for sample system.xml file
21+
- Added: Generator command for sample config.xml file
2122

2223
## [1.1.3] - 3/12/2025
2324

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,10 @@
158158
{
159159
"command": "magento-toolbox.generateSystemXmlFile",
160160
"title": "Magento Toolbox: Generate System XML"
161+
},
162+
{
163+
"command": "magento-toolbox.generateConfigXmlFile",
164+
"title": "Magento Toolbox: Generate Config XML"
161165
}
162166
],
163167
"menus": {
@@ -279,6 +283,10 @@
279283
{
280284
"command": "magento-toolbox.generateSystemXmlFile",
281285
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
286+
},
287+
{
288+
"command": "magento-toolbox.generateConfigXmlFile",
289+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
282290
}
283291
]
284292
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { SimpleTemplateGeneratorCommand } from './SimpleTemplateGeneratorCommand';
2+
import { TemplateWizardData } from 'wizard/SimpleTemplateWizard';
3+
import FileHeader from 'common/xml/FileHeader';
4+
5+
export default class GenerateConfigXmlFileCommand extends SimpleTemplateGeneratorCommand {
6+
constructor() {
7+
super('magento-toolbox.generateConfigXmlFile');
8+
}
9+
10+
getWizardTitle(): string {
11+
return 'Config XML File';
12+
}
13+
14+
getFileHeader(data: TemplateWizardData): string | undefined {
15+
return FileHeader.getHeader(data.module);
16+
}
17+
18+
getFilePath(data: TemplateWizardData): string {
19+
const [vendor, module] = data.module.split('_');
20+
21+
return `app/code/${vendor}/${module}/etc/config.xml`;
22+
}
23+
24+
getTemplateName(data: TemplateWizardData): string {
25+
return 'xml/blank-config';
26+
}
27+
}

src/command/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ export { default as GenerateMviewXmlFileCommand } from './GenerateMviewXmlFileCo
2424
export { default as GenerateWidgetXmlFileCommand } from './GenerateWidgetXmlFileCommand';
2525
export { default as GenerateExtensionAttributesXmlFileCommand } from './GenerateExtensionAttributesXmlFileCommand';
2626
export { default as GenerateSystemXmlFileCommand } from './GenerateSystemXmlFileCommand';
27+
export { default as GenerateConfigXmlFileCommand } from './GenerateConfigXmlFileCommand';

templates/xml/blank-config.ejs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0"?>
2+
<% if (fileHeader) { -%>
3+
<%- fileHeader %>
4+
<% } -%>
5+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
7+
</config>

0 commit comments

Comments
 (0)