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 .LayoutXmlData ;
22
23
import com .magento .idea .magento2plugin .actions .generation .data .MenuXmlData ;
23
24
import com .magento .idea .magento2plugin .actions .generation .data .ModelData ;
24
- import com .magento .idea .magento2plugin .actions .generation .data .GetListQueryModelData ;
25
25
import com .magento .idea .magento2plugin .actions .generation .data .PreferenceDiXmFileData ;
26
26
import com .magento .idea .magento2plugin .actions .generation .data .ResourceModelData ;
27
27
import com .magento .idea .magento2plugin .actions .generation .data .RoutesXmlData ;
28
28
import com .magento .idea .magento2plugin .actions .generation .data .SaveEntityCommandData ;
29
+ import com .magento .idea .magento2plugin .actions .generation .data .SaveEntityControllerFileData ;
29
30
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentDataProviderData ;
30
31
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentFormButtonData ;
31
32
import com .magento .idea .magento2plugin .actions .generation .data .UiComponentFormFieldData ;
40
41
import com .magento .idea .magento2plugin .actions .generation .generator .DataModelInterfaceGenerator ;
41
42
import com .magento .idea .magento2plugin .actions .generation .generator .DbSchemaWhitelistJsonGenerator ;
42
43
import com .magento .idea .magento2plugin .actions .generation .generator .DbSchemaXmlGenerator ;
44
+ import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
43
45
import com .magento .idea .magento2plugin .actions .generation .generator .LayoutXmlGenerator ;
44
46
import com .magento .idea .magento2plugin .actions .generation .generator .MenuXmlGenerator ;
45
47
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleCollectionGenerator ;
46
48
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleControllerClassGenerator ;
47
49
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleModelGenerator ;
48
50
import com .magento .idea .magento2plugin .actions .generation .generator .ModuleResourceModelGenerator ;
49
- import com .magento .idea .magento2plugin .actions .generation .generator .GetListQueryModelGenerator ;
50
51
import com .magento .idea .magento2plugin .actions .generation .generator .PreferenceDiXmlGenerator ;
51
52
import com .magento .idea .magento2plugin .actions .generation .generator .RoutesXmlGenerator ;
53
+ import com .magento .idea .magento2plugin .actions .generation .generator .SaveEntityControllerFileGenerator ;
52
54
import com .magento .idea .magento2plugin .actions .generation .generator .SaveEntityCommandGenerator ;
53
55
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentDataProviderGenerator ;
54
56
import com .magento .idea .magento2plugin .actions .generation .generator .UiComponentFormGenerator ;
62
64
import com .magento .idea .magento2plugin .magento .files .ModuleMenuXml ;
63
65
import com .magento .idea .magento2plugin .magento .files .ResourceModelPhp ;
64
66
import com .magento .idea .magento2plugin .magento .files .UiComponentDataProviderPhp ;
67
+ import com .magento .idea .magento2plugin .magento .files .actions .SaveActionFile ;
65
68
import com .magento .idea .magento2plugin .magento .files .commands .SaveEntityCommandFile ;
66
69
import com .magento .idea .magento2plugin .magento .packages .Areas ;
67
70
import com .magento .idea .magento2plugin .magento .packages .File ;
110
113
"PMD.ExcessiveImports" ,
111
114
"PMD.GodClass" ,
112
115
"PMD.TooManyMethods" ,
113
- "PMD.CyclomaticComplexity"
116
+ "PMD.CyclomaticComplexity" ,
117
+ "PMD.ExcessiveClassLength"
114
118
})
115
119
public class NewEntityDialog extends AbstractDialog {
116
120
@ NotNull
@@ -282,7 +286,7 @@ private void onOK() {
282
286
283
287
generateRoutesXmlFile ();
284
288
generateViewControllerFile ();
285
- generateSubmitControllerFile ();
289
+ generateSaveControllerFile ();
286
290
generateModelGetListQueryFile ();
287
291
generateSaveEntityCommandFile ();
288
292
generateDataProviderFile ();
@@ -307,6 +311,49 @@ private void onOK() {
307
311
this .setVisible (false );
308
312
}
309
313
314
+ /**
315
+ * Generate Save Controller file.
316
+ */
317
+ private void generateSaveControllerFile () {
318
+ final NamespaceBuilder dtoModelNamespace = getDataModelNamespace ();
319
+ final NamespaceBuilder dtoInterfaceModelNamespace = getDataModelInterfaceNamespace ();
320
+ final NamespaceBuilder namespace = new NamespaceBuilder (
321
+ getModuleName (),
322
+ SaveActionFile .CLASS_NAME ,
323
+ SaveActionFile .getDirectory (getEntityName ())
324
+ );
325
+ final String dtoType ;
326
+
327
+ if (createInterface .isSelected ()) {
328
+ dtoType = dtoInterfaceModelNamespace .getClassFqn ();
329
+ } else {
330
+ dtoType = dtoModelNamespace .getClassFqn ();
331
+ }
332
+
333
+ new SaveEntityControllerFileGenerator (new SaveEntityControllerFileData (
334
+ getEntityName (),
335
+ getModuleName (),
336
+ namespace .getNamespace (),
337
+ getSaveEntityCommandClassFqn (),
338
+ dtoType ,
339
+ getAcl (),
340
+ getEntityIdColumn ()
341
+ ), project ).generate (ACTION_NAME , false );
342
+ }
343
+
344
+ /**
345
+ * Get save entity command class Fqn.
346
+ *
347
+ * @return String
348
+ */
349
+ private String getSaveEntityCommandClassFqn () {
350
+ //TODO: change this stub after the save command generated will be implemented.
351
+ final NamespaceBuilder namespaceBuilder =
352
+ new NamespaceBuilder (getModuleName (), "SaveCommand" , "Command/" + getEntityName ());
353
+
354
+ return namespaceBuilder .getClassFqn ();
355
+ }
356
+
310
357
private PsiFile generateModelFile () {
311
358
final NamespaceBuilder modelNamespace = getModelNamespace ();
312
359
final NamespaceBuilder resourceModelNamespace = getResourceModelNamespace ();
@@ -598,24 +645,11 @@ private String getControllerDirectory() {
598
645
return ControllerBackendPhp .DEFAULT_DIR + File .separator ;
599
646
}
600
647
601
- private PsiFile generateSubmitControllerFile () {
602
- final NamespaceBuilder namespace = new NamespaceBuilder (
603
- getModuleName (),
604
- getSubmitActionName (),
605
- getViewControllerDirectory ()
606
- );
607
- return new ModuleControllerClassGenerator (new ControllerFileData (
608
- getViewControllerDirectory (),
609
- getSubmitActionName (),
610
- getModuleName (),
611
- Areas .adminhtml .toString (),
612
- HttpMethod .POST .toString (),
613
- getAcl (),
614
- true ,
615
- namespace .getNamespace ()
616
- ), project ).generate (ACTION_NAME , false );
617
- }
618
-
648
+ /**
649
+ * Get Acl id.
650
+ *
651
+ * @return String
652
+ */
619
653
public String getAcl () {
620
654
return acl .getText ().trim ();
621
655
}
0 commit comments