Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
All Data Structures Namespaces Files Functions Variables Pages
CustomerGroupsOptionsProvider.php
Go to the documentation of this file.
1 <?php
7 
9 {
13  private $groupRepository;
14 
18  private $searchCriteriaBuilder;
19 
23  private $objectConverter;
24 
30  public function __construct(
31  \Magento\Customer\Api\GroupRepositoryInterface $groupRepository,
32  \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder,
33  \Magento\Framework\Convert\DataObject $objectConverter
34  ) {
35  $this->groupRepository = $groupRepository;
36  $this->searchCriteriaBuilder = $searchCriteriaBuilder;
37  $this->objectConverter = $objectConverter;
38  }
39 
43  public function toOptionArray()
44  {
45  $customerGroups = $this->groupRepository->getList($this->searchCriteriaBuilder->create())->getItems();
46  return $this->objectConverter->toOptionArray($customerGroups, 'id', 'code');
47  }
48 }
$groupRepository
__construct(\Magento\Customer\Api\GroupRepositoryInterface $groupRepository, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Convert\DataObject $objectConverter)
$searchCriteriaBuilder