Пример #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 normalize($object, $format = null, array $context = array())
 {
     $result = parent::normalize($object, $format, $context);
     foreach (static::$socialFields as $socialType => $fieldName) {
         if (!empty($result[$fieldName])) {
             $result[$fieldName] = $this->socialUrlFormatter->getSocialUrl($socialType, $result[$fieldName]);
         }
     }
     return $result;
 }
Пример #3
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Unknown social network type "type"
  */
 public function testGetSocialUrlNoSocial()
 {
     $formatter = new SocialUrlFormatter(array());
     $formatter->getSocialUrl('type', 'me');
 }