コード例 #1
0
 public function map(\Prototype\ContactInformation $contact)
 {
     $value = $this->simpleValue($this->vocabulary->attributes->email);
     if (!empty($value)) {
         $contact->setEmail(str_replace('mailto:', '', $value));
     }
 }
コード例 #2
0
 public function map(\Prototype\ContactInformation $contact)
 {
     $value = $this->simpleValue($this->vocabulary->attributes->nickname);
     if (!empty($value)) {
         $contact->setNickname($value);
     }
 }
コード例 #3
0
ファイル: NameMapper.php プロジェクト: lukaswerner/RdfToVCard
 public function map(\Prototype\ContactInformation $contact)
 {
     $query = 'PREFIX ' . $this->vocabulary->name . ': <' . $this->vocabulary->prefix . '> ' . 'SELECT ?familyName ?firstName ' . 'WHERE { ' . '{<' . $this->url . '> ' . $this->vocabulary->name . ':' . $this->vocabulary->attributes->lastname . ' ?familyName .} UNION ' . '{<' . $this->url . '> ' . $this->vocabulary->name . ':' . $this->vocabulary->attributes->firstname . ' ?firstName .} ' . '}';
     $result = $this->store->sparqlQuery($query);
     if (!empty($result[0]['familyName'])) {
         $contact->setLastname($result[0]['familyName']);
     }
     if (!empty($result[0]['firstName'])) {
         $contact->setFirstname($result[0]['firstName']);
     }
 }
コード例 #4
0
 public function NAttribute()
 {
     $vcard = new VObject\Component\VCard();
     $vcard->add('N', ['Werner', 'Lukas', ['Roland', 'Thomas', 'Alfred', 'Joseph'], 'B.Sc.', 'Informatik']);
     $contact = new ContactInformation();
     $contact->setLastname('Werner');
     $contact->setFirstname('Lukas');
     $contact->setAdditionalNames(['Roland', 'Thomas', 'Alfred', 'Joseph']);
     $contact->setHonorificPrefixes('B.Sc.');
     $contact->setHonorificSuffixes('Informatik');
     $this->assertEquals($vcard->serialize(), $this->object->convert($contact)->serialize());
 }
コード例 #5
0
 /**
  * Converts a ContactInformation object into a vcard
  * 
  * @param \Prototype\ContactInformation $contact contact information to convert
  * @return \Sabre\VObject\Component\VCard created vcard
  */
 public function convert(ContactInformation $contact)
 {
     $vcard = new VObject\Component\VCard();
     if ($contact->hasAttribute('lastname') || $contact->hasAttribute('firstname') || $contact->hasAttribute('additionalNames') || $contact->hasAttribute('honorificPrefixes') || $contact->hasAttribute('honorificSuffixes')) {
         $N = [$contact->hasAttribute('lastname') ? $contact->getAttribute('lastname') : '', $contact->hasAttribute('firstname') ? $contact->getAttribute('firstname') : '', $contact->hasAttribute('additionalNames') ? $contact->getAttribute('additionalNames') : '', $contact->hasAttribute('honorificPrefixes') ? $contact->getAttribute('honorificPrefixes') : '', $contact->hasAttribute('honorificSuffixes') ? $contact->getAttribute('honorificSuffixes') : ''];
         $vcard->add('N', $N);
     }
     foreach (self::$attributeMap as $key => $value) {
         if ($contact->hasAttribute($key)) {
             $vcard->add($value, $contact->getAttribute($key));
         }
     }
     return $vcard;
 }