init
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?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'])
|
||||
));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user