Skip to content

Commit de4a305

Browse files
authored
ENGCOM-5141: #16445 - getRegionHtmlSelect does not have configuration - resolved #22834
2 parents 4c394a9 + 7ff8a9e commit de4a305

File tree

1 file changed

+29
-4
lines changed
  • app/code/Magento/Directory/Block

1 file changed

+29
-4
lines changed

app/code/Magento/Directory/Block/Data.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Directory\Block;
79

810
/**
@@ -173,10 +175,33 @@ public function getRegionCollection()
173175
* Returns region html select
174176
*
175177
* @return string
178+
* @deprecated
179+
* @see getRegionSelect() method for more configurations
176180
*/
177181
public function getRegionHtmlSelect()
178182
{
183+
return $this->getRegionSelect();
184+
}
185+
186+
/**
187+
* Returns region html select
188+
*
189+
* @param null|int $value
190+
* @param string $name
191+
* @param string $id
192+
* @param string $title
193+
* @return string
194+
*/
195+
public function getRegionSelect(
196+
?int $value = null,
197+
string $name = 'region',
198+
string $id = 'state',
199+
string $title = 'State/Province'
200+
): string {
179201
\Magento\Framework\Profiler::start('TEST: ' . __METHOD__, ['group' => 'TEST', 'method' => __METHOD__]);
202+
if ($value === null) {
203+
$value = (int)$this->getRegionId();
204+
}
180205
$cacheKey = 'DIRECTORY_REGION_SELECT_STORE' . $this->_storeManager->getStore()->getId();
181206
$cache = $this->_configCacheType->load($cacheKey);
182207
if ($cache) {
@@ -188,15 +213,15 @@ public function getRegionHtmlSelect()
188213
$html = $this->getLayout()->createBlock(
189214
\Magento\Framework\View\Element\Html\Select::class
190215
)->setName(
191-
'region'
216+
$name
192217
)->setTitle(
193-
__('State/Province')
218+
__($title)
194219
)->setId(
195-
'state'
220+
$id
196221
)->setClass(
197222
'required-entry validate-state'
198223
)->setValue(
199-
(int)$this->getRegionId()
224+
$value
200225
)->setOptions(
201226
$options
202227
)->getHtml();

0 commit comments

Comments
 (0)