/** * Sets the geonameid for a user. * * @param User $user * @param integer $geonameid * * @throws InvalidArgumentException if geonameid is not valid. */ public function setGeonameId(User $user, $geonameid) { if (null === $geonameid) { return; } try { $data = $this->geonamesConnector->geoname($geonameid); $country = $data->get('country'); $user->setGeonameId($geonameid); $user->setCity($data->get('name')); if (isset($country['code'])) { $user->setCountry($country['code']); } } catch (GeonamesExceptionInterface $e) { $user->setCountry(''); $user->setCity(''); } $this->manager->update($user); }
/** * {@inheritDoc} */ public function setCity($city) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setCity', array($city)); return parent::setCity($city); }