Ejemplo n.º 1
0
 public function testSetGeonameId()
 {
     $this->user->setGeonameId(1234);
     $this->assertEquals($this->user->getGeonameId(), 1234);
     $this->user->setGeonameId(null);
     $this->assertEquals($this->user->getGeonameId(), null);
 }
Ejemplo n.º 2
0
 /**
  * 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 {
         $country = $this->geonamesConnector->geoname($geonameid)->get('country');
         $user->setGeonameId($geonameid);
         if (isset($country['code'])) {
             $user->setCountry($country['code']);
         }
     } catch (GeonamesExceptionInterface $e) {
         $user->setCountry(null);
     }
     $this->manager->update($user);
 }
 /**
  * {@inheritDoc}
  */
 public function setGeonameId($geonameId)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setGeonameId', array($geonameId));
     return parent::setGeonameId($geonameId);
 }