Skip to content

Commit d9ff7f8

Browse files
authored
Merge pull request #521 from magento/mainline-entity-manager
Code generator for a Magento Entity
2 parents f612120 + 773d57e commit d9ff7f8

File tree

291 files changed

+15838
-2564
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

291 files changed

+15838
-2564
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
66

77
## 3.2.0
88

9+
### Added
10+
11+
- Code generation for a Magento Entity in [#521](https://github.com/magento/magento2-phpstorm-plugin/pull/521)
12+
- Code generation for email templates in [#350](https://github.com/magento/magento2-phpstorm-plugin/pull/350)
13+
- Reference navigation for disabled observers in `events.xml` in [#439](https://github.com/magento/magento2-phpstorm-plugin/pull/439)
14+
- Line markers for test fixtures in [#477](https://github.com/magento/magento2-phpstorm-plugin/pull/477)
15+
16+
### Changed
17+
18+
- Added ability to set the module sequence at generating new module [#266](https://github.com/magento/magento2-phpstorm-plugin/pull/266)
19+
20+
### Fixed
21+
22+
- ArrayIndexOutOfBoundsException in the New Module Action in [#519](https://github.com/magento/magento2-phpstorm-plugin/pull/519)
23+
924
## 3.1.3
1025

1126
### Changed

resources/META-INF/plugin.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
<!-- Module file generators -->
6060
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
61+
<action id="MagentoCreateEntity" class="com.magento.idea.magento2plugin.actions.generation.NewEntityAction" />
6162
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
6263
<action id="MagentoCreateAController" class="com.magento.idea.magento2plugin.actions.generation.NewControllerAction" />
6364
<action id="MagentoCreateACronjob" class="com.magento.idea.magento2plugin.actions.generation.NewCronjobAction" />
@@ -229,6 +230,18 @@
229230
<internalFileTemplate name="Magento Data Model Interface"/>
230231
<internalFileTemplate name="Magento Module Declarative Schema XML"/>
231232
<internalFileTemplate name="Magento Module Declarative Schema Whitelist JSON"/>
233+
<internalFileTemplate name="Magento Get List Query Model"/>
234+
<internalFileTemplate name="Magento Entity Save Controller Class"/>
235+
<internalFileTemplate name="Magento Entity Data Mapper"/>
236+
<internalFileTemplate name="Magento Save Entity Command Model"/>
237+
<internalFileTemplate name="Magento Entity Index Adminhtml Controller Class"/>
238+
<internalFileTemplate name="Magento Grid Ui Component Action Column Class"/>
239+
<internalFileTemplate name="Magento PHP Form Generic Button Block Class"/>
240+
<internalFileTemplate name="Magento Entity New Action Controller Class"/>
241+
<internalFileTemplate name="Magento New Entity Layout XML"/>
242+
<internalFileTemplate name="Magento Delete Entity By Id Command"/>
243+
<internalFileTemplate name="Magento Entity Edit Action Controller Class"/>
244+
<internalFileTemplate name="Magento Entity Delete Controller Class"/>
232245

233246
<defaultLiveTemplates file="/liveTemplates/MagentoPWA.xml"/>
234247

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html lang="en">
2+
<body>
3+
<p face="verdana" size="-1">
4+
5+
</p>
6+
7+
<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
8+
<tr>
9+
<td colspan="3"><font face="verdana" size="-1">Template's predefined variables:</font></td>
10+
</tr>
11+
<tr>
12+
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
13+
<td width="10">&nbsp;</td>
14+
<td width="100%" valign="top"><font face="verdana" size="-1"></font></td>
15+
</tr>
16+
</table>
17+
</body>
18+
</html>
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
#parse("PHP File Header.php")
3+
4+
namespace ${NAMESPACE};
5+
6+
#set($uses = ${USES})
7+
#foreach ($use in $uses.split(","))
8+
use $use;
9+
#end
10+
11+
/**
12+
* Converts a collection of ${ENTITY_NAME} entities to an array of data transfer objects.
13+
*/
14+
class ${CLASS_NAME}
15+
{
16+
/**
17+
* @var ${DTO_FACTORY}
18+
*/
19+
private $entityDtoFactory;
20+
21+
/**
22+
* @param ${DTO_FACTORY} $entityDtoFactory
23+
*/
24+
public function __construct(
25+
${DTO_FACTORY} $entityDtoFactory
26+
) {
27+
$this->entityDtoFactory = $entityDtoFactory;
28+
}
29+
30+
/**
31+
* Map magento models to DTO array.
32+
*
33+
* @param ${ABSTRACT_COLLECTION} $collection
34+
*
35+
* @return array|${DTO_TYPE}[]
36+
*/
37+
public function map(${ABSTRACT_COLLECTION} $collection): array
38+
{
39+
$results = [];
40+
/** @var ${MAGENTO_MODEL_TYPE} $item */
41+
foreach ($collection->getItems() as $item) {
42+
/** @var ${DTO_TYPE}|${DATA_OBJECT} $entityDto */
43+
$entityDto = $this->entityDtoFactory->create();
44+
$entityDto->addData($item->getData());
45+
46+
#set($brackets = "[]")
47+
$results$brackets = $entityDto;
48+
}
49+
50+
return $results;
51+
}
52+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<column name="${COLUMN_NAME}">
2+
<settings>
3+
#if (${COLUMN_FILTER})
4+
<filter>${COLUMN_FILTER}</filter>
5+
#end
6+
<label translate="true">${COLUMN_LABEL}</label>
7+
</settings>
8+
</column>

resources/fileTemplates/code/Magento Grid UI Component Column.xml.html

Whitespace-only changes.

resources/fileTemplates/code/Magento Module UI Component Form Field Xml.xml.ft

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,17 @@
99
<label translate="true">${LABEL}</label>
1010
<dataScope>${NAME}</dataScope>
1111
</settings>
12+
#if(${FORM_ELEMENT} == 'checkbox')
13+
<formElements>
14+
<checkbox>
15+
<settings>
16+
<valueMap>
17+
<map name="false" xsi:type="number">0</map>
18+
<map name="true" xsi:type="number">1</map>
19+
</valueMap>
20+
<prefer>toggle</prefer>
21+
</settings>
22+
</checkbox>
23+
</formElements>
24+
#end
1225
</field>

resources/fileTemplates/code/Magento Php Form Button Block Type Back.php.ft

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

resources/fileTemplates/code/Magento Php Form Button Block Type Back.php.html

Lines changed: 0 additions & 1 deletion
This file was deleted.

resources/fileTemplates/code/Magento Php Form Button Block Type Delete.php.ft

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

0 commit comments

Comments
 (0)