countryCollection = $countryCollection; } /** * @param bool $isMultiselect * @return array */ public function toOptionArray($isMultiselect = false) { if (!$this->options) { $this->options = $this->countryCollection ->addFieldToFilter('country_id', ['nin' => $this->getExcludedCountries()]) ->loadData() ->toOptionArray(false); } $options = $this->options; if (!$isMultiselect) { array_unshift($options, ['value' => '', 'label' => __('--Please Select--')]); } return $options; } /** * If country is in list of restricted (not supported by Braintree) * * @param string $countryId * @return boolean */ public function isCountryRestricted($countryId) { return in_array($countryId, $this->getExcludedCountries()); } /** * Return list of excluded countries * @return array */ public function getExcludedCountries() { return $this->excludedCountries; } }