File tree Expand file tree Collapse file tree 6 files changed +82
-7
lines changed
resources/fileTemplates/internal
src/com/magento/idea/magento2plugin/actions/generation Expand file tree Collapse file tree 6 files changed +82
-7
lines changed Original file line number Diff line number Diff line change 2
2
#parse("PHP File Header.php")
3
3
4
4
#if (${NAMESPACE})
5
- namespace ${NAMESPACE};
5
+ namespace ${NAMESPACE};
6
6
#end
7
7
8
- interface ${NAME} {
8
+ interface ${NAME}
9
+ {
10
+ #if (${PROPERTIES})
11
+ /**
12
+ * String constants for property names
13
+ */
14
+ #set ($properties = ${PROPERTIES})
15
+ #foreach ($property in $properties.split(","))
16
+ #set ($propertyData = $property.split(";"))
17
+ #set ($propertyUpperSnake = $propertyData.get(0))
18
+ #set ($propertyLowerSnake = $propertyData.get(1))
19
+ const $propertyUpperSnake = "$propertyLowerSnake";
20
+ #end
21
+ #end
22
+ #if (${PROPERTIES})
23
+ #set ($properties = ${PROPERTIES})
24
+ #foreach ($property in $properties.split(","))
25
+ #set ($propertyData = $property.split(";"))
26
+ #set ($propertyType = $propertyData.get(2))
27
+ #set ($propertyUpperCamel = $propertyData.get(3))
28
+ #set ($propertyLowerCamel = $propertyData.get(4))
9
29
30
+ /**
31
+ * @return $propertyType
32
+ */
33
+ public function get$propertyUpperCamel();
34
+
35
+ /**
36
+ * @param $propertyType $$propertyLowerCamel
37
+ * @return $this
38
+ */
39
+ public function set$propertyUpperCamel($$propertyLowerCamel);
40
+ #end
41
+ #end
10
42
}
Original file line number Diff line number Diff line change 2
2
#parse("PHP File Header.php")
3
3
4
4
#if (${NAMESPACE})
5
- namespace ${NAMESPACE};
5
+ namespace ${NAMESPACE};
6
6
#end
7
7
8
8
#set ($uses = ${USES})
9
9
#foreach ($use in $uses.split(","))
10
- use $use;
10
+ use $use;
11
11
#end
12
12
13
- class ${NAME} #if (${EXTENDS})extends ${EXTENDS} #end #if (${IMPLEMENTS})implements ${IMPLEMENTS}#end {
13
+ class ${NAME} #if (${EXTENDS})extends ${EXTENDS} #end #if (${IMPLEMENTS})implements ${IMPLEMENTS}#end
14
+ {
15
+ #if (${PROPERTIES})
16
+ #set ($properties = ${PROPERTIES})
17
+ #foreach ($property in $properties.split(","))
18
+ #set ($propertyData = $property.split(";"))
19
+ #set ($propertyUpperSnake = $propertyData.get(0))
20
+ #set ($propertyUpperCamel = $propertyData.get(3))
21
+ #set ($propertyLowerCamel = $propertyData.get(4))
22
+ #if(!($foreach.first))
14
23
24
+ #end
25
+ /**
26
+ * @inheritDoc
27
+ */
28
+ public function get$propertyUpperCamel()
29
+ {
30
+ return $this->getData(self::$propertyUpperSnake);
31
+ }
32
+
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ public function set$propertyUpperCamel($$propertyLowerCamel)
37
+ {
38
+ return $this->setData(self::$propertyUpperSnake, $$propertyLowerCamel);
39
+ }
40
+ #end
41
+ #end
15
42
}
Original file line number Diff line number Diff line change @@ -11,19 +11,22 @@ public class DataModelData {
11
11
private final String moduleName ;
12
12
private final String fqn ;
13
13
private final String interfaceFQN ;
14
+ private final String properties ;
14
15
15
16
public DataModelData (
16
17
final String namespace ,
17
18
final String name ,
18
19
final String moduleName ,
19
20
final String fqn ,
20
- final String interfaceFQN
21
+ final String interfaceFQN ,
22
+ final String properties
21
23
) {
22
24
this .namespace = namespace ;
23
25
this .name = name ;
24
26
this .moduleName = moduleName ;
25
27
this .fqn = fqn ;
26
28
this .interfaceFQN = interfaceFQN ;
29
+ this .properties = properties ;
27
30
}
28
31
29
32
public String getNamespace () {
@@ -45,4 +48,8 @@ public String getFQN() {
45
48
public String getInterfaceFQN () {
46
49
return interfaceFQN ;
47
50
}
51
+
52
+ public String getProperties () {
53
+ return properties ;
54
+ }
48
55
}
Original file line number Diff line number Diff line change @@ -10,17 +10,20 @@ public class DataModelInterfaceData {
10
10
private final String name ;
11
11
private final String moduleName ;
12
12
private final String fqn ;
13
+ private final String properties ;
13
14
14
15
public DataModelInterfaceData (
15
16
final String namespace ,
16
17
final String name ,
17
18
final String moduleName ,
18
- final String fqn
19
+ final String fqn ,
20
+ final String properties
19
21
) {
20
22
this .namespace = namespace ;
21
23
this .name = name ;
22
24
this .moduleName = moduleName ;
23
25
this .fqn = fqn ;
26
+ this .properties = properties ;
24
27
}
25
28
26
29
public String getNamespace () {
@@ -38,4 +41,8 @@ public String getModuleName() {
38
41
public String getFQN () {
39
42
return fqn ;
40
43
}
44
+
45
+ public String getProperties () {
46
+ return properties ;
47
+ }
41
48
}
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ protected void fillAttributes(Properties attributes) {
105
105
"IMPLEMENTS" ,
106
106
PhpClassGeneratorUtil .getNameFromFqn (modelData .getInterfaceFQN ())
107
107
);
108
+ attributes .setProperty ("PROPERTIES" , modelData .getProperties ());
108
109
}
109
110
110
111
private List <String > getUses () {
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ public PsiFile generate(String actionName) {
95
95
protected void fillAttributes (Properties attributes ) {
96
96
attributes .setProperty ("NAME" , interfaceData .getName ());
97
97
attributes .setProperty ("NAMESPACE" , interfaceData .getNamespace ());
98
+ attributes .setProperty ("PROPERTIES" , interfaceData .getProperties ());
98
99
}
99
100
100
101
private PhpClass createInterface (String actionName ) {
You can’t perform that action at this time.
0 commit comments