@@ 110-129 (lines=20) @@ | ||
107 | * @param array $countryData |
|
108 | * @return null|Country |
|
109 | */ |
|
110 | protected function getCountry($locale, array $countryData) |
|
111 | { |
|
112 | if (empty($countryData['iso2Code']) || empty($countryData['iso3Code'])) { |
|
113 | return null; |
|
114 | } |
|
115 | ||
116 | /** @var $country Country */ |
|
117 | $country = $this->countryRepository->findOneBy(array('iso2Code' => $countryData['iso2Code'])); |
|
118 | if (!$country) { |
|
119 | $country = new Country($countryData['iso2Code']); |
|
120 | $country->setIso3Code($countryData['iso3Code']); |
|
121 | } |
|
122 | ||
123 | $countryName = $this->translate($countryData['iso2Code'], static::COUNTRY_PREFIX, $locale); |
|
124 | ||
125 | $country->setLocale($locale) |
|
126 | ->setName($countryName); |
|
127 | ||
128 | return $country; |
|
129 | } |
|
130 | ||
131 | /** |
|
132 | * @param string $locale |
|
@@ 137-157 (lines=21) @@ | ||
134 | * @param array $regionData |
|
135 | * @return null|Region |
|
136 | */ |
|
137 | protected function getRegion($locale, Country $country, array $regionData) |
|
138 | { |
|
139 | if (empty($regionData['combinedCode']) || empty($regionData['code'])) { |
|
140 | return null; |
|
141 | } |
|
142 | ||
143 | /** @var $region Region */ |
|
144 | $region = $this->regionRepository->findOneBy(array('combinedCode' => $regionData['combinedCode'])); |
|
145 | if (!$region) { |
|
146 | $region = new Region($regionData['combinedCode']); |
|
147 | $region->setCode($regionData['code']) |
|
148 | ->setCountry($country); |
|
149 | } |
|
150 | ||
151 | $regionName = $this->translate($regionData['combinedCode'], static::REGION_PREFIX, $locale); |
|
152 | ||
153 | $region->setLocale($locale) |
|
154 | ->setName($regionName); |
|
155 | ||
156 | return $region; |
|
157 | } |
|
158 | ||
159 | /** |
|
160 | * Load countries and regions to DB |