Skip to content

Commit 71a4e84

Browse files
committed
chore: Refactor setTemplate setter info construction data
1 parent 8677610 commit 71a4e84

3 files changed

Lines changed: 37 additions & 19 deletions

File tree

Form/Field/FieldFactory.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ public function __construct(
2020
public function createWithBlock(
2121
array $data = []
2222
) {
23-
$block = $this->layout->createBlock(Template::class);
24-
$block->setTemplate('Loki_AdminComponents::form/field.phtml'); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
23+
$block = $this->layout->createBlock(Template::class, '', [
24+
'data' => [
25+
'template' => 'Loki_AdminComponents::form/field.phtml',
26+
]
27+
]);
2528
return $this->create($block, $data);
2629
}
2730

Grid/Filter/Filter.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,11 @@ public function getConditionType(): string
3636

3737
public function render(): string
3838
{
39-
$block = $this->layout->createBlock(Template::class);
40-
$block->setTemplate('Loki_AdminComponents::form/field.phtml'); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
39+
$block = $this->layout->createBlock(Template::class, '', [
40+
'data' => [
41+
'template' => 'Loki_AdminComponents::form/field.phtml',
42+
]
43+
]);
4144
$block->setField($this->getFormField($block));
4245

4346
return $block->toHtml();

Service/CategorySelection/CategoryTreeRenderer.php

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,45 @@ public function __construct(
2525

2626
public function renderMainScript(Field $field): string
2727
{
28-
return $this->layout->createBlock(Template::class, 'category_selection_main_script')
29-
->setData('field', $field)
30-
->setTemplate($this->getMainScript())
31-
->toHtml(); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
28+
return $this->layout->createBlock(Template::class, 'category_selection_main_script', [
29+
'data' => [
30+
'field' => $field,
31+
'template' => $this->getMainScript(),
32+
]
33+
])
34+
->toHtml();
3235
}
3336

3437
public function renderChildNode(CategoryTreeNode $categoryTreeNode, Field $field): string
3538
{
36-
return $this->layout->createBlock(Template::class, 'category_selection_inner_item_' . $categoryTreeNode->id)
37-
->setData('category_tree_node', $categoryTreeNode)
38-
->setData('field', $field)
39-
->setTemplate($this->getChildItemTemplate())
40-
->toHtml(); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
39+
return $this->layout->createBlock(Template::class, 'category_selection_inner_item_' . $categoryTreeNode->id, [
40+
'data' => [
41+
'category_tree_node' => $categoryTreeNode,
42+
'field' => $field,
43+
'template' => $this->getChildItemTemplate(),
44+
]
45+
])
46+
->toHtml();
4147
}
4248

4349
public function renderBreadcrumb(): string
4450
{
45-
return $this->layout->createBlock(Template::class, 'categories_selection_crumbs')
46-
->setTemplate($this->getBreadcrumbsTemplate())
47-
->toHtml(); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
51+
return $this->layout->createBlock(Template::class, 'categories_selection_crumbs', [
52+
'data' => [
53+
'template' => $this->getBreadcrumbsTemplate(),
54+
]
55+
])
56+
->toHtml();
4857
}
4958

5059
public function renderSearchInput(): string
5160
{
52-
return $this->layout->createBlock(Template::class, 'category_selection_search_input')
53-
->setTemplate($this->getSearchInputTemplate())
54-
->toHtml(); // @phpstan-ignore bitExpertMagento.setTemplateDisallowedForBlock
61+
return $this->layout->createBlock(Template::class, 'category_selection_search_input', [
62+
'data' => [
63+
'template' => $this->getSearchInputTemplate(),
64+
]
65+
])
66+
->toHtml();
5567
}
5668

5769
/**

0 commit comments

Comments
 (0)