18
18
import com .magento .idea .magento2plugin .actions .generation .data .DataModelData ;
19
19
import com .magento .idea .magento2plugin .actions .generation .data .DataModelInterfaceData ;
20
20
import com .magento .idea .magento2plugin .actions .generation .data .DbSchemaXmlData ;
21
+ import com .magento .idea .magento2plugin .actions .generation .data .GetListQueryModelData ;
21
22
import com .magento .idea .magento2plugin .actions .generation .data .EntityDataMapperData ;
22
23
import com .magento .idea .magento2plugin .actions .generation .data .GetListQueryModelData ;
23
24
import com .magento .idea .magento2plugin .actions .generation .data .LayoutXmlData ;
26
27
import com .magento .idea .magento2plugin .actions .generation .data .PreferenceDiXmFileData ;
27
28
import com .magento .idea .magento2plugin .actions .generation .data .ResourceModelData ;
28
29
import com .magento .idea .magento2plugin .actions .generation .data .RoutesXmlData ;
30
+ import com .magento .idea .magento2plugin .actions .generation .data .SaveEntityControllerFileData ;
29
31
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentDataProviderData ;
30
32
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentFormButtonData ;
31
33
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentFormFieldData ;
40
42
import com .magento .idea .magento2plugin .actions .generation .generator .DataModelInterfaceGenerator ;
41
43
import com .magento .idea .magento2plugin .actions .generation .generator .DbSchemaWhitelistJsonGenerator ;
42
44
import com .magento .idea .magento2plugin .actions .generation .generator .DbSchemaXmlGenerator ;
45
+ import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
43
46
import com .magento .idea .magento2plugin .actions .generation .generator .EntityDataMapperGenerator ;
44
47
import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
45
48
import com .magento .idea .magento2plugin .actions .generation .generator .LayoutXmlGenerator ;
50
53
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleResourceModelGenerator ;
51
54
import com .magento .idea .magento2plugin .actions .generation .generator .PreferenceDiXmlGenerator ;
52
55
import com .magento .idea .magento2plugin .actions .generation .generator .RoutesXmlGenerator ;
56
+ import com .magento .idea .magento2plugin .actions .generation .generator .SaveEntityControllerFileGenerator ;
53
57
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentDataProviderGenerator ;
54
58
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentFormGenerator ;
55
59
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentGridXmlGenerator ;
63
67
import com .magento .idea .magento2plugin .magento .files .ModuleMenuXml ;
64
68
import com .magento .idea .magento2plugin .magento .files .ResourceModelPhp ;
65
69
import com .magento .idea .magento2plugin .magento .files .UiComponentDataProviderPhp ;
70
+ import com .magento .idea .magento2plugin .magento .files .actions .SaveActionFile ;
66
71
import com .magento .idea .magento2plugin .magento .packages .Areas ;
67
72
import com .magento .idea .magento2plugin .magento .packages .File ;
68
73
import com .magento .idea .magento2plugin .magento .packages .HttpMethod ;
111
116
"PMD.GodClass" ,
112
117
"PMD.TooManyMethods" ,
113
118
"PMD.CyclomaticComplexity" ,
114
- "PMD.ExcessiveClassLength" ,
119
+ "PMD.ExcessiveClassLength"
115
120
})
116
121
public class NewEntityDialog extends AbstractDialog {
117
122
@ NotNull
@@ -283,7 +288,7 @@ private void onOK() {
283
288
284
289
generateRoutesXmlFile ();
285
290
generateViewControllerFile ();
286
- generateSubmitControllerFile ();
291
+ generateSaveControllerFile ();
287
292
generateEntityDataMapperFile ();
288
293
generateModelGetListQueryFile ();
289
294
generateDataProviderFile ();
@@ -308,6 +313,49 @@ private void onOK() {
308
313
this .setVisible (false );
309
314
}
310
315
316
+ /**
317
+ * Generate Save Controller file.
318
+ */
319
+ private void generateSaveControllerFile () {
320
+ final NamespaceBuilder dtoModelNamespace = getDataModelNamespace ();
321
+ final NamespaceBuilder dtoInterfaceModelNamespace = getDataModelInterfaceNamespace ();
322
+ final NamespaceBuilder namespace = new NamespaceBuilder (
323
+ getModuleName (),
324
+ SaveActionFile .CLASS_NAME ,
325
+ SaveActionFile .getDirectory (getEntityName ())
326
+ );
327
+ final String dtoType ;
328
+
329
+ if (createInterface .isSelected ()) {
330
+ dtoType = dtoInterfaceModelNamespace .getClassFqn ();
331
+ } else {
332
+ dtoType = dtoModelNamespace .getClassFqn ();
333
+ }
334
+
335
+ new SaveEntityControllerFileGenerator (new SaveEntityControllerFileData (
336
+ getEntityName (),
337
+ getModuleName (),
338
+ namespace .getNamespace (),
339
+ getSaveEntityCommandClassFqn (),
340
+ dtoType ,
341
+ getAcl (),
342
+ getEntityIdColumn ()
343
+ ), project ).generate (ACTION_NAME , false );
344
+ }
345
+
346
+ /**
347
+ * Get save entity command class Fqn.
348
+ *
349
+ * @return String
350
+ */
351
+ private String getSaveEntityCommandClassFqn () {
352
+ //TODO: change this stub after the save command generated will be implemented.
353
+ final NamespaceBuilder namespaceBuilder =
354
+ new NamespaceBuilder (getModuleName (), "SaveCommand" , "Command/" + getEntityName ());
355
+
356
+ return namespaceBuilder .getClassFqn ();
357
+ }
358
+
311
359
private PsiFile generateModelFile () {
312
360
final NamespaceBuilder modelNamespace = getModelNamespace ();
313
361
final NamespaceBuilder resourceModelNamespace = getResourceModelNamespace ();
@@ -579,24 +627,11 @@ private String getControllerDirectory() {
579
627
return ControllerBackendPhp .DEFAULT_DIR + File .separator ;
580
628
}
581
629
582
- private PsiFile generateSubmitControllerFile () {
583
- final NamespaceBuilder namespace = new NamespaceBuilder (
584
- getModuleName (),
585
- getSubmitActionName (),
586
- getViewControllerDirectory ()
587
- );
588
- return new ModuleControllerClassGenerator (new ControllerFileData (
589
- getViewControllerDirectory (),
590
- getSubmitActionName (),
591
- getModuleName (),
592
- Areas .adminhtml .toString (),
593
- HttpMethod .POST .toString (),
594
- getAcl (),
595
- true ,
596
- namespace .getNamespace ()
597
- ), project ).generate (ACTION_NAME , false );
598
- }
599
-
630
+ /**
631
+ * Get Acl id.
632
+ *
633
+ * @return String
634
+ */
600
635
public String getAcl () {
601
636
return acl .getText ().trim ();
602
637
}
0 commit comments