Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Source.php
Go to the documentation of this file.
1 <?php
7 namespace Magento\Tax\Model\Rate;
8 
13 use Magento\Tax\Model\Rate\Provider as RateProvider;
14 
19 {
23  protected $options;
24 
28  protected $taxRateRepository;
29 
34 
38  protected $converter;
39 
43  protected $rateProvider;
44 
53  public function __construct(
57  RateProvider $rateProvider = null
58  ) {
59  $this->taxRateRepository = $taxRateRepository;
60  $this->searchCriteriaBuilder = $searchCriteriaBuilder;
61  $this->converter = $converter;
62  $this->rateProvider = $rateProvider ?: ObjectManager::getInstance()->get(RateProvider::class);
63  }
64 
70  public function toOptionArray()
71  {
72  if (!$this->options) {
73  $searchCriteria = $this->searchCriteriaBuilder
74  ->setPageSize($this->rateProvider->getPageSize())
75  ->setCurrentPage(1)
76  ->create();
77 
78  $this->options = $this->rateProvider->toOptionArray($searchCriteria);
79  }
80 
81  return $this->options;
82  }
83 }
__construct(TaxRateRepositoryInterface $taxRateRepository, SearchCriteriaBuilder $searchCriteriaBuilder, Converter $converter, RateProvider $rateProvider=null)
Definition: Source.php:53
$searchCriteria