Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RegionSource.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
10 use Magento\Directory\Model\ResourceModel\Region\CollectionFactory;
12 
19 {
25  private $regionCollectionFactory;
26 
32  private $sourceData;
33 
37  public function __construct(CollectionFactory $regionCollectionFactory)
38  {
39  $this->regionCollectionFactory = $regionCollectionFactory;
40  }
41 
45  public function toOptionArray()
46  {
47  if (null === $this->sourceData) {
48  $regionCollection = $this->regionCollectionFactory->create();
49  $this->sourceData = $regionCollection->toOptionArray();
50  }
51  return $this->sourceData;
52  }
53 }
__construct(CollectionFactory $regionCollectionFactory)