Skip to content

Commit afa8cee

Browse files
author
Vitaliy Boyko
committed
Fixed and adjusted tests
1 parent 76be864 commit afa8cee

File tree

16 files changed

+152
-403
lines changed

16 files changed

+152
-403
lines changed

resources/fileTemplates/internal/Magento Module Ui Grid Collection Data Provider Php.php.ft

Lines changed: 0 additions & 130 deletions
This file was deleted.

resources/fileTemplates/internal/Magento Module Ui Grid Collection Data Provider Php.php.html

Lines changed: 0 additions & 40 deletions
This file was deleted.

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,25 @@
77

88
@SuppressWarnings({"PMD.DataClass"})
99
public class UiComponentDataProviderData {
10-
private final String type;
1110
private final String name;
1211
private final String namespace;
1312
private final String path;
14-
private final String collectionFqn;
1513

1614
/**
1715
* UiComponentGridDataProviderData constructor.
1816
*
19-
* @param type String
2017
* @param name String
2118
* @param namespace String
2219
* @param path String
23-
* @param collectionFqn String
2420
*/
2521
public UiComponentDataProviderData(
26-
final String type,
2722
final String name,
2823
final String namespace,
29-
final String path,
30-
final String collectionFqn
24+
final String path
3125
) {
32-
this.type = type;
3326
this.name = name;
3427
this.namespace = namespace;
3528
this.path = path;
36-
this.collectionFqn = collectionFqn;
3729
}
3830

3931
/**
@@ -54,24 +46,6 @@ public String getNamespace() {
5446
return namespace;
5547
}
5648

57-
/**
58-
* Get collection FQN.
59-
*
60-
* @return String
61-
*/
62-
public String getCollectionFqn() {
63-
return collectionFqn;
64-
}
65-
66-
/**
67-
* Get type of data provider.
68-
*
69-
* @return String
70-
*/
71-
public String getType() {
72-
return type;
73-
}
74-
7549
/**
7650
* Get path.
7751
*

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentFormDialog.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,11 +437,9 @@ private void onOK() {
437437
private PsiFile generateDataProviderFile() {
438438
final NamespaceBuilder namespace = getDataProviderNamespace();
439439
return new UiComponentDataProviderGenerator(new UiComponentDataProviderData(
440-
UiComponentDataProviderPhp.CUSTOM_TYPE,
441440
getDataProviderClassName(),
442441
namespace.getNamespace(),
443-
getDataProviderDirectory(),
444-
""
442+
getDataProviderDirectory()
445443
), getModuleName(), project).generate(NewUiComponentFormAction.ACTION_NAME, false);
446444
}
447445

src/com/magento/idea/magento2plugin/actions/generation/dialog/NewUiComponentGridDialog.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,9 @@ public static void open(final Project project, final PsiDirectory directory) {
254254
*/
255255
public UiComponentDataProviderData getGridDataProviderData() {
256256
return new UiComponentDataProviderData(
257-
getDataProviderType(),
258257
getDataProviderClass(),
259258
getDataProviderNamespace(),
260-
getDataProviderDirectory(),
261-
getCollection()
259+
getDataProviderDirectory()
262260
);
263261
}
264262

src/com/magento/idea/magento2plugin/actions/generation/generator/UiComponentDataProviderGenerator.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,18 +111,6 @@ public PsiFile generate(final String actionName) {
111111
protected void fillAttributes(final Properties attributes) {
112112
attributes.setProperty("NAMESPACE", uiComponentGridDataProviderData.getNamespace());
113113
attributes.setProperty("CLASS_NAME", uiComponentGridDataProviderData.getName());
114-
final String dataProviderType = uiComponentGridDataProviderData.getType();
115-
116-
if (dataProviderType.equals(UiComponentDataProviderPhp.COLLECTION_TYPE)) {
117-
attributes.setProperty(
118-
"COLLECTION_CLASS_FQN",
119-
uiComponentGridDataProviderData.getCollectionFqn()
120-
);
121-
attributes.setProperty(
122-
"COLLECTION_CLASS_NAME",
123-
getNameFromFqn(uiComponentGridDataProviderData.getCollectionFqn())
124-
);
125-
}
126114
}
127115

128116
private PhpClass createDataProviderClass(final String actionName) {
@@ -142,8 +130,7 @@ private PhpClass createDataProviderClass(final String actionName) {
142130

143131
dataProviderFile = fileFromTemplateGenerator.generate(
144132
UiComponentDataProviderPhp.getInstance(
145-
uiComponentGridDataProviderData.getName(),
146-
uiComponentGridDataProviderData.getType()
133+
uiComponentGridDataProviderData.getName()
147134
),
148135
attributes,
149136
parentDirectory,

src/com/magento/idea/magento2plugin/magento/files/UiComponentDataProviderPhp.java

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,35 +14,29 @@
1414
"PMD.RedundantFieldInitializer"
1515
})
1616
public class UiComponentDataProviderPhp implements ModuleFileInterface {
17-
public static final String COLLECTION_TEMPLATE =
18-
"Magento Module Ui Grid Collection Data Provider Php";
1917
public static final String CUSTOM_TEMPLATE = "Magento Module Ui Custom Data Provider Php";
2018
public static final String FILE_EXTENSION = "php";
2119
public static final String CUSTOM_TYPE = "custom";
2220
public static final String COLLECTION_TYPE = "collection";
2321
private static UiComponentDataProviderPhp INSTANCE = null;
2422
private String className;
25-
private String providerType;
2623
public static final String DEFAULT_DATA_PROVIDER =
2724
"Magento\\Framework\\View\\Element\\UiComponent\\DataProvider\\DataProvider";
2825

2926
/**
3027
* Returns a new instance of the class.
3128
*
3229
* @param className DataProvider class name
33-
* @param providerType DataProvider type
3430
* @return UiComponentGridDataProviderPhp
3531
*/
3632
public static UiComponentDataProviderPhp getInstance(
37-
final String className,
38-
final String providerType
33+
final String className
3934
) {
4035
if (null == INSTANCE) {
4136
INSTANCE = new UiComponentDataProviderPhp();
4237
}
4338

4439
INSTANCE.setClassName(className);
45-
INSTANCE.setProviderType(providerType);
4640

4741
return INSTANCE;
4842
}
@@ -56,31 +50,14 @@ public void setClassName(final String className) {
5650
this.className = className;
5751
}
5852

59-
/**
60-
* Set provided type.
61-
*
62-
* @param providerType String
63-
*/
64-
public void setProviderType(final String providerType) {
65-
this.providerType = providerType;
66-
}
67-
6853
@Override
6954
public String getFileName() {
7055
return String.format("%s.%s", className, FILE_EXTENSION);
7156
}
7257

7358
@Override
7459
public String getTemplate() {
75-
if (providerType.equals(COLLECTION_TYPE)) {
76-
return COLLECTION_TEMPLATE;
77-
}
78-
79-
if (providerType.equals(CUSTOM_TYPE)) {
80-
return CUSTOM_TEMPLATE;
81-
}
82-
83-
return null;
60+
return CUSTOM_TEMPLATE;
8461
}
8562

8663
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4+
<virtualType name="MyVirtualClass" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult">
5+
<arguments>
6+
<argument name="resourceModel" xsi:type="string">My/Collection</argument>
7+
<argument name="mainTable" xsi:type="string">my_table</argument>
8+
</arguments>
9+
</virtualType>
10+
<type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
11+
<arguments>
12+
<argument xsi:type="array">
13+
<item xsi:type="string" name="my_grid_data_source">MyVirtualClass</item>
14+
</argument>
15+
</arguments>
16+
</type>
17+
</config>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Backend:etc/menu.xsd">
4+
<menu>
5+
<add id="Foo_Bar::menu" sortOrder="10" title="My Title" module="Foo_Bar" parent="Magento_Customer::customer"
6+
resource="Foo_Bar::acl" translate="title" action="test"/>
7+
</menu>
8+
</config>

testData/actions/generation/generator/ModuleControllerClassGenerator/generateBackendControllerFile/BackendSaveAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ class BackendSaveAction extends Action implements HttpPostActionInterface
2323
*/
2424
public function execute()
2525
{
26-
// TODO: Implement execute method.
26+
return $this->resultFactory->create(\Magento\Framework\Controller\ResultFactory::TYPE_PAGE);
2727
}
2828
}

0 commit comments

Comments
 (0)