3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+ declare (strict_types=1 );
7
+
6
8
namespace Magento \Directory \Block ;
7
9
8
10
/**
@@ -173,10 +175,33 @@ public function getRegionCollection()
173
175
* Returns region html select
174
176
*
175
177
* @return string
178
+ * @deprecated
179
+ * @see getRegionSelect() method for more configurations
176
180
*/
177
181
public function getRegionHtmlSelect ()
178
182
{
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 {
179
201
\Magento \Framework \Profiler::start ('TEST: ' . __METHOD__ , ['group ' => 'TEST ' , 'method ' => __METHOD__ ]);
202
+ if ($ value === null ) {
203
+ $ value = (int )$ this ->getRegionId ();
204
+ }
180
205
$ cacheKey = 'DIRECTORY_REGION_SELECT_STORE ' . $ this ->_storeManager ->getStore ()->getId ();
181
206
$ cache = $ this ->_configCacheType ->load ($ cacheKey );
182
207
if ($ cache ) {
@@ -188,15 +213,15 @@ public function getRegionHtmlSelect()
188
213
$ html = $ this ->getLayout ()->createBlock (
189
214
\Magento \Framework \View \Element \Html \Select::class
190
215
)->setName (
191
- ' region '
216
+ $ name
192
217
)->setTitle (
193
- __ (' State/Province ' )
218
+ __ ($ title )
194
219
)->setId (
195
- ' state '
220
+ $ id
196
221
)->setClass (
197
222
'required-entry validate-state '
198
223
)->setValue (
199
- ( int ) $ this -> getRegionId ()
224
+ $ value
200
225
)->setOptions (
201
226
$ options
202
227
)->getHtml ();
0 commit comments