Skip to content

Commit 4a2fcd2

Browse files
Added Web API generation support for entity creator feature
1 parent 9fbde76 commit 4a2fcd2

File tree

39 files changed

+620
-48
lines changed

39 files changed

+620
-48
lines changed

resources/fileTemplates/internal/Magento Entity Delete Controller Class.php.ft

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ${CLASS_NAME} extends ${EXTENDS} implements ${IMPLEMENTS_POST}, ${IMPLEMEN
2727

2828
/**
2929
* @param Context $context
30-
* @param DeleteByIdCommand $deleteByIdCommand
30+
* @param ${DELETE_COMMAND} $deleteByIdCommand
3131
*/
3232
public function __construct(
3333
${CONTEXT} $context,

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class DeleteEntityByIdCommandData {
1414
private final String entityId;
1515
private final String modelName;
1616
private final String resourceModelName;
17+
private final String aclResource;
1718

1819
/**
1920
* Delete Command DTO Constructor.
@@ -23,19 +24,22 @@ public class DeleteEntityByIdCommandData {
2324
* @param entityId String
2425
* @param modelName String
2526
* @param resourceModelName String
27+
* @param aclResource String
2628
*/
2729
public DeleteEntityByIdCommandData(
2830
final @NotNull String moduleName,
2931
final @NotNull String entityName,
3032
final @NotNull String entityId,
3133
final @NotNull String modelName,
32-
final @NotNull String resourceModelName
34+
final @NotNull String resourceModelName,
35+
final @NotNull String aclResource
3336
) {
3437
this.moduleName = moduleName;
3538
this.entityName = entityName;
3639
this.entityId = entityId;
3740
this.modelName = modelName;
3841
this.resourceModelName = resourceModelName;
42+
this.aclResource = aclResource;
3943
}
4044

4145
/**
@@ -82,4 +86,13 @@ public String getModelName() {
8286
public String getResourceModelName() {
8387
return resourceModelName;
8488
}
89+
90+
/**
91+
* Get ACL resource.
92+
*
93+
* @return String
94+
*/
95+
public String getAclResource() {
96+
return aclResource;
97+
}
8598
}

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class DeleteEntityControllerFileData {
1313
private final String moduleName;
1414
private final String acl;
1515
private final String entityId;
16+
private final boolean isDeleteCommandHasInterface;
1617

1718
/**
1819
* Controller Delete file constructor.
@@ -26,12 +27,14 @@ public DeleteEntityControllerFileData(
2627
final @NotNull String entityName,
2728
final @NotNull String moduleName,
2829
final @NotNull String acl,
29-
final @NotNull String entityId
30+
final @NotNull String entityId,
31+
final boolean isDeleteCommandHasInterface
3032
) {
3133
this.entityName = entityName;
3234
this.moduleName = moduleName;
3335
this.acl = acl;
3436
this.entityId = entityId;
37+
this.isDeleteCommandHasInterface = isDeleteCommandHasInterface;
3538
}
3639

3740
/**
@@ -69,4 +72,13 @@ public String getAcl() {
6972
public String getEntityId() {
7073
return entityId;
7174
}
75+
76+
/**
77+
* Check if delete command has Web API interface.
78+
*
79+
* @return boolean
80+
*/
81+
public boolean isDeleteCommandHasInterface() {
82+
return isDeleteCommandHasInterface;
83+
}
7284
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class GetListQueryModelData {
1313
private final String entityName;
1414
private final String modelName;
1515
private final String collectionName;
16+
private final String aclResource;
1617

1718
/**
1819
* Query Model DTO Constructor.
@@ -21,17 +22,20 @@ public class GetListQueryModelData {
2122
* @param entityName String
2223
* @param modelName String
2324
* @param collectionName String
25+
* @param aclResource String
2426
*/
2527
public GetListQueryModelData(
2628
final @NotNull String moduleName,
2729
final @NotNull String entityName,
2830
final @NotNull String modelName,
29-
final @NotNull String collectionName
31+
final @NotNull String collectionName,
32+
final @NotNull String aclResource
3033
) {
3134
this.moduleName = moduleName;
3235
this.entityName = entityName;
3336
this.modelName = modelName;
3437
this.collectionName = collectionName;
38+
this.aclResource = aclResource;
3539
}
3640

3741
/**
@@ -69,4 +73,13 @@ public String getModelName() {
6973
public String getCollectionName() {
7074
return collectionName;
7175
}
76+
77+
/**
78+
* Get entity acl resource.
79+
*
80+
* @return String
81+
*/
82+
public String getAclResource() {
83+
return aclResource;
84+
}
7285
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class SaveEntityCommandData {
1616
private final String dtoName;
1717
private final String dtoInterfaceName;
1818
private final boolean dtoWithInterface;
19+
private final String aclResource;
1920

2021
/**
2122
* Save Command DTO Constructor.
@@ -27,6 +28,7 @@ public class SaveEntityCommandData {
2728
* @param dtoName String
2829
* @param dtoInterfaceName String
2930
* @param isDtoWithInterface boolean
31+
* @param aclResource String
3032
*/
3133
public SaveEntityCommandData(
3234
final @NotNull String moduleName,
@@ -35,7 +37,8 @@ public SaveEntityCommandData(
3537
final @NotNull String resourceModelName,
3638
final @NotNull String dtoName,
3739
final @NotNull String dtoInterfaceName,
38-
final boolean isDtoWithInterface
40+
final boolean isDtoWithInterface,
41+
final @NotNull String aclResource
3942
) {
4043
this.moduleName = moduleName;
4144
this.entityName = entityName;
@@ -44,6 +47,7 @@ public SaveEntityCommandData(
4447
this.dtoName = dtoName;
4548
this.dtoInterfaceName = dtoInterfaceName;
4649
this.dtoWithInterface = isDtoWithInterface;
50+
this.aclResource = aclResource;
4751
}
4852

4953
/**
@@ -108,4 +112,13 @@ public String getDtoInterfaceName() {
108112
public boolean isDtoWithInterface() {
109113
return dtoWithInterface;
110114
}
115+
116+
/**
117+
* Get ACL resource.
118+
*
119+
* @return String
120+
*/
121+
public String getAclResource() {
122+
return aclResource;
123+
}
111124
}

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class SaveEntityControllerFileData {
1616
private final String dtoName;
1717
private final String dtoInterfaceName;
1818
private final boolean dtoWithInterface;
19+
private final boolean isSaveCommandHasInterface;
1920

2021
/**
2122
* Controller save file constructor.
@@ -27,6 +28,7 @@ public class SaveEntityControllerFileData {
2728
* @param dtoName String
2829
* @param dtoInterfaceName String
2930
* @param isDtoWithInterface boolean
31+
* @param isSaveCommandHasInterface boolean
3032
*/
3133
public SaveEntityControllerFileData(
3234
final @NotNull String entityName,
@@ -35,7 +37,8 @@ public SaveEntityControllerFileData(
3537
final @NotNull String entityId,
3638
final @NotNull String dtoName,
3739
final @NotNull String dtoInterfaceName,
38-
final boolean isDtoWithInterface
40+
final boolean isDtoWithInterface,
41+
final boolean isSaveCommandHasInterface
3942
) {
4043
this.entityName = entityName;
4144
this.moduleName = moduleName;
@@ -44,6 +47,7 @@ public SaveEntityControllerFileData(
4447
this.dtoName = dtoName;
4548
this.dtoInterfaceName = dtoInterfaceName;
4649
this.dtoWithInterface = isDtoWithInterface;
50+
this.isSaveCommandHasInterface = isSaveCommandHasInterface;
4751
}
4852

4953
/**
@@ -108,4 +112,13 @@ public String getDtoInterfaceName() {
108112
public boolean isDtoWithInterface() {
109113
return dtoWithInterface;
110114
}
115+
116+
/**
117+
* Check if save command has interface.
118+
*
119+
* @return boolean
120+
*/
121+
public boolean isSaveCommandHasInterface() {
122+
return isSaveCommandHasInterface;
123+
}
111124
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public class UiComponentDataProviderData {
1111
private final String path;
1212
private final String entityName;
1313
private final String entityIdFieldName;
14+
private final boolean isQueryHasInterface;
1415

1516
/**
1617
* UiComponentGridDataProviderData constructor.
@@ -22,7 +23,7 @@ public UiComponentDataProviderData(
2223
final String name,
2324
final String path
2425
) {
25-
this(name, path, null, null);
26+
this(name, path, null, null, false);
2627
}
2728

2829
/**
@@ -32,17 +33,20 @@ public UiComponentDataProviderData(
3233
* @param path String
3334
* @param entityName String
3435
* @param entityIdFieldName String
36+
* @param isQueryHasInterface boolean
3537
*/
3638
public UiComponentDataProviderData(
3739
final String name,
3840
final String path,
3941
final String entityName,
40-
final String entityIdFieldName
42+
final String entityIdFieldName,
43+
final boolean isQueryHasInterface
4144
) {
4245
this.name = name;
4346
this.path = path;
4447
this.entityName = entityName;
4548
this.entityIdFieldName = entityIdFieldName;
49+
this.isQueryHasInterface = isQueryHasInterface;
4650
}
4751

4852
/**
@@ -80,4 +84,13 @@ public String getEntityName() {
8084
public String getEntityIdFieldName() {
8185
return entityIdFieldName;
8286
}
87+
88+
/**
89+
* Check if query service has Web API interface.
90+
*
91+
* @return boolean
92+
*/
93+
public boolean isQueryHasInterface() {
94+
return isQueryHasInterface;
95+
}
8396
}

src/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/DataProviderDtoConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public DataProviderDtoConverter(
3030
newEntityDialogData.getEntityName().concat("DataProvider"),
3131
UiComponentDataProviderFile.DIRECTORY,
3232
newEntityDialogData.getEntityName(),
33-
newEntityDialogData.getIdFieldName()
33+
newEntityDialogData.getIdFieldName(),
34+
newEntityDialogData.hasWebApi()
3435
);
3536
}
3637
}

src/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/DeleteEntityByIdCommandDtoConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ public DeleteEntityByIdCommandDtoConverter(
2929
newEntityDialogData.getEntityName(),
3030
newEntityDialogData.getIdFieldName(),
3131
newEntityDialogData.getEntityName().concat("Model"),
32-
newEntityDialogData.getEntityName().concat("Resource")
32+
newEntityDialogData.getEntityName().concat("Resource"),
33+
newEntityDialogData.getAclId()
3334
);
3435
}
3536
}

src/com/magento/idea/magento2plugin/actions/generation/data/converter/newentitydialog/FormDeleteControllerDtoConverter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ public FormDeleteControllerDtoConverter(
2828
newEntityDialogData.getEntityName(),
2929
generationContextData.getModuleName(),
3030
newEntityDialogData.getAclId(),
31-
newEntityDialogData.getIdFieldName()
31+
newEntityDialogData.getIdFieldName(),
32+
newEntityDialogData.hasWebApi()
3233
);
3334
}
3435
}

0 commit comments

Comments
 (0)