File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Loki \AdminComponents \ViewModel \Options ;
4+
5+ use Magento \Directory \Helper \Data as DirectoryHelper ;
6+ use Magento \Framework \Data \OptionSourceInterface ;
7+ use Magento \Framework \View \Element \Block \ArgumentInterface ;
8+
9+ class CountryOptions implements ArgumentInterface, OptionSourceInterface
10+ {
11+ public function __construct (
12+ private readonly DirectoryHelper $ directoryHelper ,
13+ ) {
14+ }
15+
16+ public function toOptionArray ()
17+ {
18+ $ options = [];
19+ $ options [] = [
20+ 'value ' => '' ,
21+ 'label ' => '' ,
22+ ];
23+
24+ foreach ($ this ->directoryHelper ->getCountryCollection () as $ country ) {
25+ $ options [] = [
26+ 'value ' => $ country ->getCountryId (),
27+ 'label ' => $ country ->getName (),
28+ ];
29+
30+ }
31+
32+ asort ($ options );
33+
34+ return $ options ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments