File tree 6 files changed +11
-25
lines changed
resources/fileTemplates/code
src/com/magento/idea/magento2plugin
testData/actions/generation/generator/EntityDataMapperClassGenerator/generateEntityDataMapperFile
tests/com/magento/idea/magento2plugin/actions/generation/generator
6 files changed +11
-25
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ use $use;
9
9
#end
10
10
11
11
/**
12
- * ${ENTITY_NAME} magento model collection to entity data transfer object array mapper .
12
+ * Converts a collection of ${ENTITY_NAME} entities to an array of data transfer objects .
13
13
*/
14
14
class ${CLASS_NAME}
15
15
{
Original file line number Diff line number Diff line change @@ -1019,7 +1019,7 @@ private void generateWhitelistJsonFile(final @NotNull DbSchemaXmlData dbSchemaXm
1019
1019
*/
1020
1020
private void generateEntityDataMapperFile () {
1021
1021
final EntityDataMapperFile entityDataMapperFile =
1022
- EntityDataMapperFile . getInstance (getEntityName ());
1022
+ new EntityDataMapperFile (getEntityName ());
1023
1023
1024
1024
final String namespace = entityDataMapperFile .getNamespace (getModuleName ());
1025
1025
final String classFqn = entityDataMapperFile .getClassFqn (getModuleName ());
@@ -1073,7 +1073,7 @@ private void generateModelGetListQueryFile() {
1073
1073
*/
1074
1074
private String getEntityDataMapperType () {
1075
1075
final EntityDataMapperFile entityDataMapperFile =
1076
- EntityDataMapperFile . getInstance (getEntityName ());
1076
+ new EntityDataMapperFile (getEntityName ());
1077
1077
1078
1078
return entityDataMapperFile .getClassFqn (getModuleName ());
1079
1079
}
Original file line number Diff line number Diff line change @@ -62,8 +62,7 @@ public EntityDataMapperGenerator(
62
62
this .entityDataMapperData = entityDataMapperData ;
63
63
this .project = project ;
64
64
this .checkFileAlreadyExists = checkFileAlreadyExists ;
65
- entityDataMapperFile = EntityDataMapperFile
66
- .getInstance (entityDataMapperData .getEntityName ());
65
+ entityDataMapperFile = new EntityDataMapperFile (entityDataMapperData .getEntityName ());
67
66
fileFromTemplateGenerator = FileFromTemplateGenerator .getInstance (project );
68
67
directoryGenerator = DirectoryGenerator .getInstance ();
69
68
moduleIndex = ModuleIndex .getInstance (project );
Original file line number Diff line number Diff line change 11
11
import com .magento .idea .magento2plugin .magento .packages .Package ;
12
12
import org .jetbrains .annotations .NotNull ;
13
13
14
- public final class EntityDataMapperFile implements ModuleFileInterface {
14
+ public class EntityDataMapperFile implements ModuleFileInterface {
15
15
16
16
public static final String CLASS_NAME_SUFFIX = "DataMapper" ;
17
17
public static final String FILE_EXTENSION = "php" ;
18
18
public static final String TEMPLATE = "Magento Entity Data Mapper" ;
19
19
private static final String DIRECTORY = "Mapper" ;
20
- private static EntityDataMapperFile instance ;
21
- private String className ;
20
+ private final String className ;
22
21
private String namespaceFqn ;
23
22
private String classFqn ;
24
23
25
- private EntityDataMapperFile () {}
26
-
27
24
/**
28
- * Get singleton object of entity data mapper file.
25
+ * Entity data mapper file constructor .
29
26
*
30
27
* @param entityName String
31
- *
32
- * @return EntityDataMapperFile
33
28
*/
34
- public static EntityDataMapperFile getInstance (final @ NotNull String entityName ) {
35
- synchronized (EntityDataMapperFile .class ) {
36
- if (instance == null ) {
37
- instance = new EntityDataMapperFile ();
38
- instance .className = entityName .concat (CLASS_NAME_SUFFIX );
39
- }
40
- }
41
-
42
- return instance ;
29
+ public EntityDataMapperFile (final @ NotNull String entityName ) {
30
+ this .className = entityName .concat (CLASS_NAME_SUFFIX );
43
31
}
44
32
45
33
/**
Original file line number Diff line number Diff line change 9
9
use Magento \Framework \Model \ResourceModel \Db \Collection \AbstractCollection ;
10
10
11
11
/**
12
- * Unicorn magento model collection to entity data transfer object array mapper .
12
+ * Converts a collection of Unicorn entities to an array of data transfer objects .
13
13
*/
14
14
class UnicornDataMapper
15
15
{
Original file line number Diff line number Diff line change @@ -36,8 +36,7 @@ public void testGenerateEntityDataMapperFile() {
36
36
myFixture .getProject (),
37
37
false
38
38
);
39
- final EntityDataMapperFile entityDataMapperFile =
40
- EntityDataMapperFile .getInstance (ENTITY_NAME );
39
+ final EntityDataMapperFile entityDataMapperFile = new EntityDataMapperFile (ENTITY_NAME );
41
40
final String filePath = this .getFixturePath (entityDataMapperFile .getFileName ());
42
41
43
42
assertGeneratedFileIsCorrect (
You can’t perform that action at this time.
0 commit comments