Skip to content

Commit 9515d13

Browse files
Added source model generation for EAV attribute input
1 parent c1df489 commit 9515d13

File tree

23 files changed

+1065
-165
lines changed

23 files changed

+1065
-165
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
4+
namespace ${NAMESPACE};
5+
6+
#set ($uses = ${USES})
7+
#foreach ($use in $uses.split(","))
8+
use $use;
9+
#end
10+
11+
class ${NAME} extends ${EXTENDS}
12+
{
13+
/**
14+
* Retrieve All options
15+
*
16+
* @return array
17+
*/
18+
public function getAllOptions(): array
19+
{
20+
// TODO: Implement getAllOptions() method.
21+
}
22+
}

src/com/magento/idea/magento2plugin/actions/generation/data/ProductEntityData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import com.magento.idea.magento2plugin.magento.packages.File;
99
import com.magento.idea.magento2plugin.magento.packages.Package;
10-
import com.magento.idea.magento2plugin.magento.packages.eav.EavEntities;
10+
import com.magento.idea.magento2plugin.magento.packages.eav.EavEntity;
1111

1212
@SuppressWarnings({"PMD.TooManyFields"})
1313
public class ProductEntityData implements EavEntityDataInterface {
@@ -184,7 +184,7 @@ public String getDataPatchName() {
184184

185185
@Override
186186
public String getEntityClass() {
187-
return EavEntities.PRODUCT.getEntityClass();
187+
return EavEntity.PRODUCT.getEntityClass();
188188
}
189189

190190
public String getGroup() {
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
package com.magento.idea.magento2plugin.actions.generation.data;
2+
3+
import com.magento.idea.magento2plugin.magento.files.SourceModelPhp;
4+
import com.magento.idea.magento2plugin.magento.packages.File;
5+
import com.magento.idea.magento2plugin.magento.packages.Package;
6+
7+
public class SourceModelData {
8+
private String className;
9+
private String namespace;
10+
private String moduleName;
11+
private String directory;
12+
13+
public String getClassName() {
14+
return className;
15+
}
16+
17+
/**
18+
* Constructor.
19+
*/
20+
public String getNamespace() {
21+
if (namespace == null) {
22+
namespace = getDefaultSourceModelNamespace();
23+
}
24+
25+
return namespace;
26+
}
27+
28+
/**
29+
* Provides default namespace.
30+
*
31+
* @return String
32+
*/
33+
public String getDefaultSourceModelNamespace() {
34+
final String[] parts = moduleName.split(Package.vendorModuleNameSeparator);
35+
if (parts[0] == null || parts[1] == null || parts.length > 2) {
36+
return null;
37+
}
38+
final String directoryPart = getDirectory().replace(
39+
File.separator,
40+
Package.fqnSeparator
41+
);
42+
return parts[0] + Package.fqnSeparator + parts[1] + Package.fqnSeparator + directoryPart;
43+
}
44+
45+
/**
46+
* Get default namespace.
47+
*
48+
* @return String
49+
*/
50+
public String getModuleName() {
51+
return moduleName;
52+
}
53+
54+
/**
55+
* Get directory path.
56+
*
57+
* @return String
58+
*/
59+
public String getDirectory() {
60+
if (this.directory == null) {
61+
return SourceModelPhp.DEFAULT_DIR;
62+
}
63+
64+
return this.directory;
65+
}
66+
67+
public void setClassName(final String className) {
68+
this.className = className;
69+
}
70+
71+
public void setNamespace(final String namespace) {
72+
this.namespace = namespace;
73+
}
74+
75+
public void setModuleName(final String moduleName) {
76+
this.moduleName = moduleName;
77+
}
78+
79+
public void setDirectory(final String directory) {
80+
this.directory = directory;
81+
}
82+
}

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewEavAttributeDialog.form

Lines changed: 131 additions & 28 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)