Skip to content

Commit da95f34

Browse files
committed
feat: generator for sample extension_attributes.xml file
1 parent 7e89fb4 commit da95f34

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
@@ -16,6 +16,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
1616
- Added: Generator command for sample indexer.xml file
1717
- Added: Generator command for sample mview.xml file
1818
- Added: Generator command for sample widget.xml file
19+
- Added: Generator command for sample extension_attributes.xml file
1920

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

package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@
150150
{
151151
"command": "magento-toolbox.generateWidgetXmlFile",
152152
"title": "Magento Toolbox: Generate Widget XML"
153+
},
154+
{
155+
"command": "magento-toolbox.generateExtensionAttributesXmlFile",
156+
"title": "Magento Toolbox: Generate Extension Attributes XML"
153157
}
154158
],
155159
"menus": {
@@ -263,6 +267,10 @@
263267
{
264268
"command": "magento-toolbox.generateWidgetXmlFile",
265269
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
270+
},
271+
{
272+
"command": "magento-toolbox.generateExtensionAttributesXmlFile",
273+
"when": "resourcePath =~ /app\\/code\\/.+\\/.+/i"
266274
}
267275
]
268276
}
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 GenerateExtensionAttributesXmlFileCommand extends SimpleTemplateGeneratorCommand {
6+
constructor() {
7+
super('magento-toolbox.generateExtensionAttributesXmlFile');
8+
}
9+
10+
getWizardTitle(): string {
11+
return 'Extension Attributes 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/extension_attributes.xml`;
22+
}
23+
24+
getTemplateName(data: TemplateWizardData): string {
25+
return 'xml/blank-extension-attributes';
26+
}
27+
}

src/command/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ export { default as GenerateViewXmlFile } from './GenerateViewXmlFile';
2222
export { default as GenerateIndexerXmlFileCommand } from './GenerateIndexerXmlFileCommand';
2323
export { default as GenerateMviewXmlFileCommand } from './GenerateMviewXmlFileCommand';
2424
export { default as GenerateWidgetXmlFileCommand } from './GenerateWidgetXmlFileCommand';
25+
export { default as GenerateExtensionAttributesXmlFileCommand } from './GenerateExtensionAttributesXmlFileCommand';
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:framework:Api/etc/extension_attributes.xsd">
7+
</config>

0 commit comments

Comments
 (0)