Skip to content

Code generator for a Magento Entity #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 146 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
20ef982
309: Code refactoring
bohdan-harniuk Jan 15, 2021
c01e98c
Entity manager innitial
Jan 19, 2021
0efd44f
Merge branch '3.1.0-develop' of github.com:magento/magento2-phpstorm-…
Jan 19, 2021
c473393
New Entity DB
Jan 19, 2021
e4b19ea
Fixed null pointer
Jan 20, 2021
019328f
Merge pull request #456 from magento/epic-entity-manager
Jan 20, 2021
97f5f34
Merge remote-tracking branch 'origin/mainline-entity-manager' into ma…
Jan 21, 2021
48789b9
Merge branch '309-add-db-schema-whitelist-generation' of github.com:s…
bohdan-harniuk Jan 21, 2021
70f703c
Added posibility to generate db_schema.xml and db_schema_whitelist.js…
bohdan-harniuk Jan 21, 2021
6483a70
Code refactoring after ColumnAttributes enum type was added
bohdan-harniuk Jan 21, 2021
a906b32
Added tests for db_schema.xml and db_schema_whitelist.json generation…
bohdan-harniuk Jan 22, 2021
e94b888
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Jan 22, 2021
c035056
Merge pull request #459 from bohdan-harniuk/provide-declarative-schem…
Jan 22, 2021
e1a3a80
Merge branch 'adjust-data-model-generation' of github.com:anzin/magen…
anzin Jan 22, 2021
71ade4c
Improved data model generation integrated with the entity manager
anzin Jan 22, 2021
b70044b
Prettified form
Jan 25, 2021
42fe08b
Merge pull request #461 from anzin/data-model-generation-integration-…
Jan 25, 2021
809e930
Merge branch '3.1.0-develop' of github.com:magento/magento2-phpstorm-…
Jan 25, 2021
3715ffc
Merge remote-tracking branch 'origin/mainline-entity-manager' into ma…
Jan 25, 2021
61f3f00
Added get list query model and injected into data provider
bohdan-harniuk Jan 25, 2021
d823952
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Jan 25, 2021
fbb083d
Fixed tests
bohdan-harniuk Jan 25, 2021
5a68b4c
Merge pull request #462 from bohdan-harniuk/add-query-service-generat…
Jan 26, 2021
42f855b
Added save entity command class generation
bohdan-harniuk Jan 26, 2021
cc66260
added generator for save controller
anzin Jan 28, 2021
f5da382
Added entity data mapper generator and test for generation
bohdan-harniuk Feb 2, 2021
42d1beb
Fixed few bugs with entity manager generation
bohdan-harniuk Feb 3, 2021
1c3c94d
fix for controller namespace
bohdan-harniuk Feb 3, 2021
1d702ef
Merge pull request #465 from anzin/create-save-controller-generation
Feb 3, 2021
0097124
Code refactoring after CR
bohdan-harniuk Feb 3, 2021
b6da2b7
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 3, 2021
4e9cb66
fixed merging minor mistakes
bohdan-harniuk Feb 3, 2021
31cf3a2
Code refactoring after CR
bohdan-harniuk Feb 3, 2021
30837a1
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 3, 2021
d1dee19
fixed checkStyle issues
bohdan-harniuk Feb 3, 2021
4b3ea8b
Merge pull request #470 from bohdan-harniuk/data-mapper-for-entity-ma…
Feb 3, 2021
eed20d8
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 3, 2021
1e2bdff
getSaveEntityCommandClassFqn methods stub implemented
bohdan-harniuk Feb 3, 2021
87b1022
Merge pull request #463 from bohdan-harniuk/entity-save-command-class…
Feb 3, 2021
9eedbff
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 3, 2021
101c697
Code refactoring with actualization
bohdan-harniuk Feb 3, 2021
aeba3bf
Merge pull request #473 from bohdan-harniuk/entity-manager-bug-fixing
Feb 3, 2021
3e61f96
Fixed entity manager dialog UX
anzin Feb 4, 2021
cdb963f
Fixed static-tests
anzin Feb 4, 2021
dded030
Fixed code by recomendation
anzin Feb 4, 2021
cfb68fe
Added entity columns to grid, recreated view controller, bug fixing, …
bohdan-harniuk Feb 4, 2021
5d9275a
Merge pull request #474 from anzin/fix-mainline-entity-maneger-dialog…
Feb 4, 2021
e57d130
Changed layout name according to the new controller name
bohdan-harniuk Feb 4, 2021
2f29726
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 4, 2021
cb89409
Added field name to validation message
bohdan-harniuk Feb 4, 2021
95c7134
Merge pull request #476 from bohdan-harniuk/add-entity-columns-to-grid
Feb 5, 2021
81c4b3c
UI Component form development
bohdan-harniuk Feb 5, 2021
fb5efb0
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 5, 2021
bf1d5d7
Form generic button development
bohdan-harniuk Feb 10, 2021
c93644b
Added generator for NewAction Controller
anzin Feb 10, 2021
cb17ceb
Data provider extended to provide right data into the entity form, te…
bohdan-harniuk Feb 10, 2021
aca6257
Fixed Test
anzin Feb 10, 2021
346c756
Merge pull request #478 from bohdan-harniuk/develop-ui-component-form…
Feb 10, 2021
d1c65f3
Merge branch '3.2.0-develop' of github.com:magento/magento2-phpstorm-…
Feb 10, 2021
5d35064
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
anzin Feb 10, 2021
8d3e893
Improved buttons generation, test coverage changes
bohdan-harniuk Feb 11, 2021
ebc4bee
Improved UX by adding autocompletion for entity name dependent fields
bohdan-harniuk Feb 11, 2021
f57f07b
Removed useless imports
bohdan-harniuk Feb 11, 2021
d150ec8
Merge pull request #483 from bohdan-harniuk/entity-manager-form-ux-im…
eduard13 Feb 11, 2021
ded43de
Added ui components tab toggling
bohdan-harniuk Feb 11, 2021
8447132
Fix ui component tab view
bohdan-harniuk Feb 12, 2021
0da4503
Removed border from ui component tab
bohdan-harniuk Feb 12, 2021
dbb70c2
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
anzin Feb 12, 2021
3d37faa
Merge pull request #484 from bohdan-harniuk/entity-manager-form-ux-im…
eduard13 Feb 12, 2021
f429534
Merge pull request #482 from bohdan-harniuk/ui-form-buttons-adjustments
Feb 12, 2021
55147af
Fixed code by recommendation
anzin Feb 12, 2021
4e2e13c
Fixed code
anzin Feb 12, 2021
766a29f
Changed test template file
anzin Feb 12, 2021
19e9274
Small fixes
bohdan-harniuk Feb 12, 2021
3ce4d07
Merge pull request #481 from anzin/create-new-action-controller-gener…
Feb 15, 2021
dc6cb89
Added new entity layout file generation, test for generation
bohdan-harniuk Feb 15, 2021
5a4f816
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 15, 2021
191788c
Merge pull request #487 from bohdan-harniuk/new-entity-action-layout-…
Feb 15, 2021
2bbda0a
Fixed entity saving use case flow
bohdan-harniuk Feb 15, 2021
9c54773
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Feb 15, 2021
0bb5046
Rewrited edit action generation, added test case for edit action gene…
bohdan-harniuk Feb 15, 2021
813aed5
Changed boolean field view on the form, converted labels for fields
anzin Feb 16, 2021
b756009
Fixed data provider to work with listing and form
anzin Feb 16, 2021
dbb584c
Small fixes
bohdan-harniuk Feb 17, 2021
ca7f84c
Merge pull request #490 from anzin/ui-form-field-adjustments
eduard13 Feb 17, 2021
8f9f189
Added Generator Delete Entity By Id
anzin Feb 17, 2021
3a91fe9
Code improvements
eduard13 Feb 17, 2021
9c4be7f
Added Generator for Delete Controller
anzin Feb 17, 2021
0ce2e33
Merge pull request #489 from anzin/fixed-data-provider
eduard13 Feb 17, 2021
b3146e0
Fixed code by recommendation
anzin Feb 18, 2021
82a4bc2
Merge pull request #492 from anzin/add-generator-delete-command
Feb 18, 2021
79111d5
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
anzin Feb 18, 2021
39da774
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Mar 2, 2021
572aa55
Merge pull request #491 from bohdan-harniuk/save-entity-flow-development
Mar 2, 2021
e92ab1d
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
anzin Mar 2, 2021
0b0e6ea
Merge pull request #493 from anzin/add-generator-for-delete-controller
Mar 3, 2021
79a7744
Capitalizing the entity name in order to correctly use it for generat…
eduard13 Mar 11, 2021
17a6c03
Merge pull request #506 from eduard13/entity-manager-capitalize-entit…
Mar 11, 2021
59015e0
Entity manager refactoring, main part of code
bohdan-harniuk Mar 12, 2021
690c7eb
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Mar 12, 2021
b28a710
Additional development after the branch updating, bug fix
bohdan-harniuk Mar 12, 2021
7bc0a29
Made generate and validate methods public
bohdan-harniuk Mar 13, 2021
65ad74d
Added testing for entity manager in pool generation, showed message i…
bohdan-harniuk Mar 13, 2021
efee2aa
Merge pull request #509 from bohdan-harniuk/entity-manager-refactoring
Mar 14, 2021
922666c
Renamed Entity Manager to Entity Creator
bohdan-harniuk Mar 15, 2021
d9ddba6
Removed unused import
bohdan-harniuk Mar 15, 2021
94e4d80
Generalized message for the user
bohdan-harniuk Mar 15, 2021
32e57c9
Updated messages
bohdan-harniuk Mar 15, 2021
45a9286
Merge pull request #510 from bohdan-harniuk/entity-creator-generator-…
Mar 15, 2021
8c00b0c
Enhanced UX with generation process, generation in the separate threa…
bohdan-harniuk Mar 15, 2021
817c217
Merge pull request #511 from bohdan-harniuk/entity-creator-enhance-ux…
eduard13 Mar 17, 2021
1ca8d8d
Enhanced Model, Resource Model, Collection generation, fixed collecti…
bohdan-harniuk Mar 17, 2021
3bfd3b1
Merge pull request #512 from bohdan-harniuk/enhancing-model-resource-…
eduard13 Mar 19, 2021
8921267
Enhanced and refactored bunch of generators and all related files and…
bohdan-harniuk Mar 19, 2021
bd1270d
Merge pull request #514 from bohdan-harniuk/enhancing-models-genertor…
eduard13 Mar 22, 2021
eb3aa96
Focusing on the first text field
eduard13 Mar 22, 2021
a4859d0
Merge pull request #515 from eduard13/form-field-focus
Mar 24, 2021
a3f4ed1
Validation enhanced to show all errors above the fields on the form
bohdan-harniuk Mar 24, 2021
e658ebc
Changed error message position (below the field)
bohdan-harniuk Mar 24, 2021
0ddea1a
Merge pull request #516 from bohdan-harniuk/enhancing-dialog-validation
eduard13 Mar 24, 2021
09faed8
Refactored entity creator generators, removed unnecessary namespace b…
bohdan-harniuk Mar 25, 2021
ebeab55
Merge pull request #517 from bohdan-harniuk/refactoring-entity-creato…
eduard13 Mar 26, 2021
ac85ebc
Added navigation to tab with error on field
bohdan-harniuk Mar 26, 2021
5911974
Updated CHANGELOG.md
Mar 30, 2021
3703b72
Merge remote-tracking branch 'origin/mainline-entity-manager' into ma…
Mar 30, 2021
9868a52
Merge pull request #518 from bohdan-harniuk/navigate-to-tab-with-error
eduard13 Mar 30, 2021
35eee16
Php file generators refactoring - model, resource model, collection, …
bohdan-harniuk Mar 31, 2021
603ceb3
Added validation for fields
anzin Mar 31, 2021
261748e
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
anzin Mar 31, 2021
8dede1a
Fixing typo
eduard13 Mar 31, 2021
18fbdcc
Merge pull request #522 from anzin/entity-creator-fields-validation
eduard13 Mar 31, 2021
33bf56d
Merge branch 'mainline-entity-manager' of github.com:magento/magento2…
bohdan-harniuk Mar 31, 2021
4ba56b8
Merge branch '3.2.0-develop' of github.com:magento/magento2-phpstorm-…
bohdan-harniuk Mar 31, 2021
58f5762
Additional changes after branch updating
bohdan-harniuk Mar 31, 2021
22d7358
Generators adjustments and critical bugs fixing
bohdan-harniuk Mar 31, 2021
8b4198d
Merge pull request #523 from bohdan-harniuk/php-file-generators-refac…
Apr 2, 2021
fc40807
Enhabced validation, added filtering for fields to validate on entity…
bohdan-harniuk Apr 2, 2021
8a6846b
Added highlighting reseting before validation
bohdan-harniuk Apr 2, 2021
faa2ce6
Merge pull request #524 from bohdan-harniuk/enhancing-abstract-dialog…
eduard13 Apr 2, 2021
9699581
Refactored php file generators to extend PhpFileGenerator, fixed stat…
bohdan-harniuk Apr 4, 2021
1a73c59
Changed actions column and edit page buttons generation, added new te…
bohdan-harniuk Apr 6, 2021
36ea1c9
Merge pull request #526 from bohdan-harniuk/refactoring-entity-creato…
Apr 7, 2021
519026b
Static fixes, fixed observer reference
Apr 7, 2021
b1390d3
Test fixes
Apr 7, 2021
c065a5a
Fixed Windows compatibility
Apr 7, 2021
773d57e
Fixed Windows compatibility 2
Apr 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).

## 3.2.0

### Added

- Code generation for a Magento Entity in [#521](https://github.com/magento/magento2-phpstorm-plugin/pull/521)
- Code generation for email templates in [#350](https://github.com/magento/magento2-phpstorm-plugin/pull/350)
- Reference navigation for disabled observers in `events.xml` in [#439](https://github.com/magento/magento2-phpstorm-plugin/pull/439)
- Line markers for test fixtures in [#477](https://github.com/magento/magento2-phpstorm-plugin/pull/477)

### Changed

- Added ability to set the module sequence at generating new module [#266](https://github.com/magento/magento2-phpstorm-plugin/pull/266)

### Fixed

- ArrayIndexOutOfBoundsException in the New Module Action in [#519](https://github.com/magento/magento2-phpstorm-plugin/pull/519)

## 3.1.3

### Changed
Expand Down
13 changes: 13 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@

<!-- Module file generators -->
<group id="MagentoNewModuleFileGroup" class="com.magento.idea.magento2plugin.actions.groups.NewModuleFileGroup" text="Module File" popup="true">
<action id="MagentoCreateEntity" class="com.magento.idea.magento2plugin.actions.generation.NewEntityAction" />
<action id="MagentoCreateABlock" class="com.magento.idea.magento2plugin.actions.generation.NewBlockAction" />
<action id="MagentoCreateAController" class="com.magento.idea.magento2plugin.actions.generation.NewControllerAction" />
<action id="MagentoCreateACronjob" class="com.magento.idea.magento2plugin.actions.generation.NewCronjobAction" />
Expand Down Expand Up @@ -229,6 +230,18 @@
<internalFileTemplate name="Magento Data Model Interface"/>
<internalFileTemplate name="Magento Module Declarative Schema XML"/>
<internalFileTemplate name="Magento Module Declarative Schema Whitelist JSON"/>
<internalFileTemplate name="Magento Get List Query Model"/>
<internalFileTemplate name="Magento Entity Save Controller Class"/>
<internalFileTemplate name="Magento Entity Data Mapper"/>
<internalFileTemplate name="Magento Save Entity Command Model"/>
<internalFileTemplate name="Magento Entity Index Adminhtml Controller Class"/>
<internalFileTemplate name="Magento Grid Ui Component Action Column Class"/>
<internalFileTemplate name="Magento PHP Form Generic Button Block Class"/>
<internalFileTemplate name="Magento Entity New Action Controller Class"/>
<internalFileTemplate name="Magento New Entity Layout XML"/>
<internalFileTemplate name="Magento Delete Entity By Id Command"/>
<internalFileTemplate name="Magento Entity Edit Action Controller Class"/>
<internalFileTemplate name="Magento Entity Delete Controller Class"/>

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

Expand Down
18 changes: 18 additions & 0 deletions resources/fileTemplates/code/Magento Entity Data Mapper.html.ft
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html lang="en">
<body>
<p face="verdana" size="-1">

</p>

<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
<tr>
<td colspan="3"><font face="verdana" size="-1">Template's predefined variables:</font></td>
</tr>
<tr>
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
<td width="10">&nbsp;</td>
<td width="100%" valign="top"><font face="verdana" size="-1"></font></td>
</tr>
</table>
</body>
</html>
52 changes: 52 additions & 0 deletions resources/fileTemplates/code/Magento Entity Data Mapper.php.ft
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
#parse("PHP File Header.php")

namespace ${NAMESPACE};

#set($uses = ${USES})
#foreach ($use in $uses.split(","))
use $use;
#end

/**
* Converts a collection of ${ENTITY_NAME} entities to an array of data transfer objects.
*/
class ${CLASS_NAME}
{
/**
* @var ${DTO_FACTORY}
*/
private $entityDtoFactory;

/**
* @param ${DTO_FACTORY} $entityDtoFactory
*/
public function __construct(
${DTO_FACTORY} $entityDtoFactory
) {
$this->entityDtoFactory = $entityDtoFactory;
}

/**
* Map magento models to DTO array.
*
* @param ${ABSTRACT_COLLECTION} $collection
*
* @return array|${DTO_TYPE}[]
*/
public function map(${ABSTRACT_COLLECTION} $collection): array
{
$results = [];
/** @var ${MAGENTO_MODEL_TYPE} $item */
foreach ($collection->getItems() as $item) {
/** @var ${DTO_TYPE}|${DATA_OBJECT} $entityDto */
$entityDto = $this->entityDtoFactory->create();
$entityDto->addData($item->getData());

#set($brackets = "[]")
$results$brackets = $entityDto;
}

return $results;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<column name="${COLUMN_NAME}">
<settings>
#if (${COLUMN_FILTER})
<filter>${COLUMN_FILTER}</filter>
#end
<label translate="true">${COLUMN_LABEL}</label>
</settings>
</column>
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,17 @@
<label translate="true">${LABEL}</label>
<dataScope>${NAME}</dataScope>
</settings>
#if(${FORM_ELEMENT} == 'checkbox')
<formElements>
<checkbox>
<settings>
<valueMap>
<map name="false" xsi:type="number">0</map>
<map name="true" xsi:type="number">1</map>
</valueMap>
<prefer>toggle</prefer>
</settings>
</checkbox>
</formElements>
#end
</field>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php
#parse("PHP File Header.php")

namespace ${NAMESPACE};

#set($uses = ${USES})
#foreach ($use in $uses.split(","))
use $use;
#end

/**
* Delete ${ENTITY_NAME} by id Command.
*/
class ${CLASS_NAME}
{
/**
* @var ${LOGGER}
*/
private $logger;

/**
* @var ${MODEL_FACTORY}
*/
private $modelFactory;

/**
* @var ${RESOURCE}
*/
private $resource;

/**
* @param ${LOGGER} $logger
* @param ${MODEL_FACTORY} $modelFactory
* @param ${RESOURCE} $resource
*/
public function __construct(
${LOGGER} $logger,
${MODEL_FACTORY} $modelFactory,
${RESOURCE} $resource
) {
$this->logger = $logger;
$this->modelFactory = $modelFactory;
$this->resource = $resource;
}

/**
* Delete ${ENTITY_NAME}.
*
* @param int $entityId
*
* @return void
* @throws ${COULD_NOT_DELETE}|${NO_SUCH_ENTITY_EXCEPTION}
*/
public function execute(int $entityId)
{
try {
/** @var ${MODEL} $model */
$model = $this->modelFactory->create();
$this->resource->load($model, $entityId, '${ENTITY_ID}');

if (!$model->getData('${ENTITY_ID}')) {
throw new ${NO_SUCH_ENTITY_EXCEPTION}(
__('Could not find ${ENTITY_NAME} with id: `%id`',
[
'id' => $entityId
]
)
);
}

$this->resource->delete($model);
} catch (Exception $exception) {
$this->logger->error(
__('Could not delete ${ENTITY_NAME}. Original message: {message}'),
[
'message' => $exception->getMessage(),
'exception' => $exception
]
);
throw new ${COULD_NOT_DELETE}(__('Could not delete ${ENTITY_NAME}.'));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html lang="en">
<body>
<p face="verdana" size="-1">

</p>

<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
<tr>
<td colspan="3"><font face="verdana" size="-1">Template's predefined variables:</font></td>
</tr>
<tr>
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
<td width="10">&nbsp;</td>
<td width="100%" valign="top"><font face="verdana" size="-1"></font></td>
</tr>
</table>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
#parse("PHP File Header.php")

namespace ${NAMESPACE};

#set($uses = ${USES})
#foreach ($use in $uses.split(","))
use $use;
#end

/**
* Delete ${ENTITY_NAME} controller.
*/
class ${CLASS_NAME} extends ${EXTENDS} implements ${IMPLEMENTS_POST}, ${IMPLEMENTS_GET}
{
/**
* Authorization level of a basic admin session.
*
* @see _isAllowed()
*/
const ADMIN_RESOURCE = '${ADMIN_RESOURCE}';

/**
* @var ${DELETE_COMMAND}
*/
private $deleteByIdCommand;

/**
* @param Context $context
* @param DeleteByIdCommand $deleteByIdCommand
*/
public function __construct(
${CONTEXT} $context,
${DELETE_COMMAND} $deleteByIdCommand
) {
parent::__construct($context);
$this->deleteByIdCommand = $deleteByIdCommand;
}

/**
* Delete ${ENTITY_NAME} action.
*
* @return ${RESULT_INTERFACE}
*/
public function execute()
{
/** @var ${RESULT_INTERFACE} $resultRedirect */
$resultRedirect = $this->resultFactory->create(${RESULT_FACTORY}::TYPE_REDIRECT);
$resultRedirect->setPath('*/*/');
$entityId = (int) $this->getRequest()->getParam('${ENTITY_ID}');

try {
$this->deleteByIdCommand->execute($entityId);
$this->messageManager->addSuccessMessage(__('You have successfully deleted ${ENTITY_NAME} entity'));
} catch (${COULD_NOT_DELETE} | ${NO_SUCH_ENTITY_EXCEPTION} $exception) {
$this->messageManager->addErrorMessage($exception->getMessage());
}

return $resultRedirect;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html lang="en">
<body>
<p face="verdana" size="-1">

</p>

<table width="100%" border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse">
<tr>
<td colspan="3"><font face="verdana" size="-1">Template's predefined variables:</font></td>
</tr>
<tr>
<td valign="top"><nobr><font face="verdana" size="-2"><b>${NAMESPACE}</b></font></nobr></td>
<td width="10">&nbsp;</td>
<td width="100%" valign="top"><font face="verdana" size="-1"></font></td>
</tr>
</table>
</body>
</html>
Loading