示例#1
0
 /**
  * @param string $socialType
  * @param string $username
  * @return string
  */
 public function getSocialUrl($socialType, $username)
 {
     if (!$socialType || !$username) {
         return '#';
     }
     return $this->socialUrlFormatter->getSocialUrl($socialType, $username);
 }
示例#2
0
 /**
  * {@inheritdoc}
  */
 public function denormalize($data, $class, $format = null, array $context = array())
 {
     foreach (static::$socialFields as $socialType => $fieldName) {
         if (!empty($data[$fieldName])) {
             $data[$fieldName] = $this->socialUrlFormatter->getSocialUsername($socialType, $data[$fieldName]);
         }
     }
     return parent::denormalize($data, $class, $format, $context);
 }
示例#3
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Unknown social network type "type"
  */
 public function testGetSocialUsernameNoSocial()
 {
     $formatter = new SocialUrlFormatter(array());
     $formatter->getSocialUsername('type', 'me');
 }