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 22#parse("PHP File Header.php")
33
44#if (${NAMESPACE})
5- namespace ${NAMESPACE};
5+ namespace ${NAMESPACE};
66#end
77
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))
929
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
1042}
Original file line number Diff line number Diff line change 22#parse("PHP File Header.php")
33
44#if (${NAMESPACE})
5- namespace ${NAMESPACE};
5+ namespace ${NAMESPACE};
66#end
77
88#set ($uses = ${USES})
99#foreach ($use in $uses.split(","))
10- use $use;
10+ use $use;
1111#end
1212
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))
1423
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
1542}
Original file line number Diff line number Diff line change @@ -11,19 +11,22 @@ public class DataModelData {
1111 private final String moduleName ;
1212 private final String fqn ;
1313 private final String interfaceFQN ;
14+ private final String properties ;
1415
1516 public DataModelData (
1617 final String namespace ,
1718 final String name ,
1819 final String moduleName ,
1920 final String fqn ,
20- final String interfaceFQN
21+ final String interfaceFQN ,
22+ final String properties
2123 ) {
2224 this .namespace = namespace ;
2325 this .name = name ;
2426 this .moduleName = moduleName ;
2527 this .fqn = fqn ;
2628 this .interfaceFQN = interfaceFQN ;
29+ this .properties = properties ;
2730 }
2831
2932 public String getNamespace () {
@@ -45,4 +48,8 @@ public String getFQN() {
4548 public String getInterfaceFQN () {
4649 return interfaceFQN ;
4750 }
51+
52+ public String getProperties () {
53+ return properties ;
54+ }
4855}
Original file line number Diff line number Diff line change @@ -10,17 +10,20 @@ public class DataModelInterfaceData {
1010 private final String name ;
1111 private final String moduleName ;
1212 private final String fqn ;
13+ private final String properties ;
1314
1415 public DataModelInterfaceData (
1516 final String namespace ,
1617 final String name ,
1718 final String moduleName ,
18- final String fqn
19+ final String fqn ,
20+ final String properties
1921 ) {
2022 this .namespace = namespace ;
2123 this .name = name ;
2224 this .moduleName = moduleName ;
2325 this .fqn = fqn ;
26+ this .properties = properties ;
2427 }
2528
2629 public String getNamespace () {
@@ -38,4 +41,8 @@ public String getModuleName() {
3841 public String getFQN () {
3942 return fqn ;
4043 }
44+
45+ public String getProperties () {
46+ return properties ;
47+ }
4148}
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ protected void fillAttributes(Properties attributes) {
105105 "IMPLEMENTS" ,
106106 PhpClassGeneratorUtil .getNameFromFqn (modelData .getInterfaceFQN ())
107107 );
108+ attributes .setProperty ("PROPERTIES" , modelData .getProperties ());
108109 }
109110
110111 private List <String > getUses () {
Original file line number Diff line number Diff line change @@ -95,6 +95,7 @@ public PsiFile generate(String actionName) {
9595 protected void fillAttributes (Properties attributes ) {
9696 attributes .setProperty ("NAME" , interfaceData .getName ());
9797 attributes .setProperty ("NAMESPACE" , interfaceData .getNamespace ());
98+ attributes .setProperty ("PROPERTIES" , interfaceData .getProperties ());
9899 }
99100
100101 private PhpClass createInterface (String actionName ) {
You can’t perform that action at this time.
0 commit comments