Skip to content

Commit bed5432

Browse files
committed
Settings cleanup
1 parent bd0e3e9 commit bed5432

File tree

5 files changed

+4
-29
lines changed

5 files changed

+4
-29
lines changed

src/fields/EasyAddressFieldField.php

+1-5
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ public function getInputHtml($value, ElementInterface $element = null): string
176176
$id = Craft::$app->getView()->formatInputId($this->handle);
177177
$namespacedId = Craft::$app->getView()->namespaceInputId($id);
178178

179-
$pluginSettings = EasyAddressField::getInstance()->getSettings();
180-
$fieldSettings = $this->getSettings();
181-
182179
return Craft::$app->getView()->renderTemplate(
183180
'easy-address-field/_field/_input',
184181
[
@@ -188,8 +185,7 @@ public function getInputHtml($value, ElementInterface $element = null): string
188185
'id' => $id,
189186
'countries' => EasyAddressField::getInstance()->countries->getCountriesAsArray(),
190187
'namespacedId' => $namespacedId,
191-
'fieldSettings' => $fieldSettings,
192-
'pluginSettings' => $pluginSettings,
188+
'fieldSettings' => $this->getSettings(),
193189
]
194190
);
195191
}

src/services/CountriesService.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public function getCountryNameByAlpha2($code, $locale)
3232
$country = $data->alpha2($code);
3333

3434
try {
35-
$translatedLocale = Locale::getDisplayRegion('-' . $country['alpha2'], $locale);
36-
return $translatedLocale;
35+
return Locale::getDisplayRegion('-' . $country['alpha2'], $locale);
3736
} catch (\Exception $e) {
3837
return $country['name'];
3938
}

src/services/GeoLocationService.php

-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@
99

1010
class GeoLocationService extends Component
1111
{
12-
public $settings;
13-
14-
public function init(): void
15-
{
16-
parent::init(); // TODO: Change the autogenerated stub
17-
$this->settings = EasyAddressField::getInstance()->getSettings();
18-
}
19-
2012
/**
2113
* @param EasyAddressFieldModel $model
2214
*

src/translations/nl/easy-address-field.php

-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
'Postal code' => 'Postcode',
1515
'City' => 'Stad of gemeente',
1616
'Pick an address on the map' => 'Kies een adres op de kaart',
17-
1817
];

src/web/twig/variables/AddressVariable.php

+2-13
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,11 @@
33
namespace studioespresso\easyaddressfield\web\twig\variables;
44

55
use studioespresso\easyaddressfield\EasyAddressField;
6-
use studioespresso\easyaddressfield\services\CountriesService;
76

87
class AddressVariable
98
{
10-
private $settings;
11-
12-
public function __construct()
9+
public function countries(): array
1310
{
14-
$pluginSettings = EasyAddressField::getInstance()->getSettings();
15-
$this->settings = $pluginSettings;
16-
}
17-
18-
public function countries()
19-
{
20-
$countriesService = new CountriesService();
21-
22-
return $countriesService->getCountriesAsArray();
11+
return EasyAddressField::getInstance()->countries->getCountriesAsArray();
2312
}
2413
}

0 commit comments

Comments
 (0)