sourceRepository = $sourceRepository; $this->searchCriteriaBuilder = $searchCriteriaBuilder; } /** * Retrieve option array * * @return string[] */ public function getOptionArray() { $searchCriteria = $this->searchCriteriaBuilder->create(); $sources = $this->sourceRepository->getList($searchCriteria)->getItems(); $options = []; foreach ($sources as $source) { $options[$source->getSourceCode()] = $source->getName(); } return $options; } /** * Get options * * @return array */ public function getAllOptions() { $searchCriteria = $this->searchCriteriaBuilder->create(); $sources = $this->sourceRepository->getList($searchCriteria)->getItems(); $options = []; foreach ($sources as $source) { $options[] = [ 'value' => $source->getSourceCode(), 'label' => $source->getName() ]; } return $options; } /** * Retrieve option text by option value * * @return array */ public function toOptionArray() { return $this->getAllOptions(); } }