Skip to content

Commit 27dee04

Browse files
committed
feat: generator for sample system.xml file
1 parent da95f34 commit 27dee04

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

CHANGELOG.md

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

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

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@
154154
{
155155
"command": "magento-toolbox.generateExtensionAttributesXmlFile",
156156
"title": "Magento Toolbox: Generate Extension Attributes XML"
157+
},
158+
{
159+
"command": "magento-toolbox.generateSystemXmlFile",
160+
"title": "Magento Toolbox: Generate System XML"
157161
}
158162
],
159163
"menus": {
@@ -271,6 +275,10 @@
271275
{
272276
"command": "magento-toolbox.generateExtensionAttributesXmlFile",
273277
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
278+
},
279+
{
280+
"command": "magento-toolbox.generateSystemXmlFile",
281+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
274282
}
275283
]
276284
}
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 GenerateSystemXmlFileCommand extends SimpleTemplateGeneratorCommand {
6+
constructor() {
7+
super('magento-toolbox.generateSystemXmlFile');
8+
}
9+
10+
getFileHeader(data: TemplateWizardData): string | undefined {
11+
return FileHeader.getHeader(data.module);
12+
}
13+
14+
getWizardTitle(): string {
15+
return 'System XML File';
16+
}
17+
18+
getFilePath(data: TemplateWizardData): string {
19+
const [vendor, module] = data.module.split('_');
20+
21+
return `app/code/${vendor}/${module}/etc/adminhtml/system.xml`;
22+
}
23+
24+
getTemplateName(data: TemplateWizardData): string {
25+
return 'xml/blank-system';
26+
}
27+
}

src/command/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ export { default as GenerateIndexerXmlFileCommand } from './GenerateIndexerXmlFi
2323
export { default as GenerateMviewXmlFileCommand } from './GenerateMviewXmlFileCommand';
2424
export { default as GenerateWidgetXmlFileCommand } from './GenerateWidgetXmlFileCommand';
2525
export { default as GenerateExtensionAttributesXmlFileCommand } from './GenerateExtensionAttributesXmlFileCommand';
26+
export { default as GenerateSystemXmlFileCommand } from './GenerateSystemXmlFileCommand';

templates/xml/blank-system.ejs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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_Config:etc/system_file.xsd">
7+
<system>
8+
</system>
9+
</config>

0 commit comments

Comments
 (0)