Skip to content

Commit c75f0d4

Browse files
author
Vitaliy
authored
Merge pull request #534 from ProkopovVitaliy/532-source-model-generation-for-eav-attribute-input
Added source model generation for EAV attribute input
2 parents d0d0cb4 + f59095f commit c75f0d4

File tree

23 files changed

+1095
-165
lines changed

23 files changed

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

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)