init
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Agent\Model\Source;
|
||||
|
||||
use Magento\Framework\Data\OptionSourceInterface;
|
||||
|
||||
class Continent implements OptionSourceInterface
|
||||
{
|
||||
public function toOptionArray(): array
|
||||
{
|
||||
return [
|
||||
['value' => 'africa', 'label' => __('Africa')],
|
||||
['value' => 'asia', 'label' => __('Asia')],
|
||||
['value' => 'europe', 'label' => __('Europe')],
|
||||
['value' => 'north_america', 'label' => __('North America')],
|
||||
['value' => 'south_america', 'label' => __('South America')],
|
||||
['value' => 'oceania', 'label' => __('Oceania')],
|
||||
['value' => 'antarctica', 'label' => __('Antarctica')],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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