Skip to content

Commit 3a91fe9

Browse files
committed
Code improvements
1 parent b756009 commit 3a91fe9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

resources/fileTemplates/internal/Magento UI Component Custom Data Provider Class.php.ft

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,13 @@ class ${CLASS_NAME} extends ${EXTENDS}
106106

107107
#set($entityId = "#if(${ENTITY_ID})${ENTITY_ID}#{else}entity_id#end")
108108
#set($entityIdAccessor = '[(int) $item[' + "'$entityId'" + ']]')
109-
#set($getIdFromParamsAccessor = "[(int) $this->request->getParam('$entityId')]")
109+
#set($getIdAccessor = "[(int) $id]")
110110
foreach ($this->loadedData['items'] as $item) {
111111
$itemsById$entityIdAccessor = $item;
112112
}
113113

114-
if ($this->request->getParam('$entityId')) {
115-
$this->loadedData['entity'] = $itemsById$getIdFromParamsAccessor;
114+
if ($id = $this->request->getParam('$entityId', null)) {
115+
$this->loadedData['entity'] = $itemsById$getIdAccessor;
116116
}
117117

118118
return $this->loadedData;

testData/actions/generation/generator/UiComponentGridDataProviderGenerator/generateDataProviderWithInjectedGetListQuery/GridDataProvider.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public function getData(): array
105105
$itemsById[(int)$item['entity_id']] = $item;
106106
}
107107

108-
if ($this->request->getParam('entity_id')) {
109-
$this->loadedData['entity'] = $itemsById[(int)$this->request->getParam('entity_id')];
108+
if ($id = $this->request->getParam('entity_id', null)) {
109+
$this->loadedData['entity'] = $itemsById[(int)$id];
110110
}
111111

112112
return $this->loadedData;

0 commit comments

Comments
 (0)