27 lines
736 B
PHP
27 lines
736 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\Agent\Model\Source;
|
|
|
|
use Esun\Agent\Model\Map\CountryPosition;
|
|
use Magento\Directory\Model\Config\Source\Country;
|
|
use Magento\Framework\Data\OptionSourceInterface;
|
|
|
|
class MapCountry implements OptionSourceInterface
|
|
{
|
|
public function __construct(
|
|
private readonly Country $countrySource,
|
|
private readonly CountryPosition $countryPosition
|
|
) {
|
|
}
|
|
|
|
public function toOptionArray(): array
|
|
{
|
|
return array_values(array_filter(
|
|
$this->countrySource->toOptionArray(),
|
|
fn (array $option): bool => (string) ($option['value'] ?? '') === ''
|
|
|| $this->countryPosition->has((string) $option['value'])
|
|
));
|
|
}
|
|
}
|