/**
* Returns a vcard for a profile
* @param $profile
* @param $includePhoto
* @return VCard
*/
public function getVCard($profile, $includePhoto)
{
$vcard = new VCard();
$vcard->addName($profile['lastName'], $profile['firstName'])->addCompany($profile['company'])->addAddress('', '', $profile['address']['street'], $profile['address']['city'], $profile['address']['region'], $profile['address']['zip'], $profile['address']['country'])->addEmail($profile['email'])->addURL($profile['url'])->addPhoneNumber($profile['phone']['work'], 'WORK')->addPhoneNumber($profile['phone']['mobile'], 'CELL')->addJobtitle($profile['jobTitle']);
// Add photo
if ($profile['photo'] != null) {
$photoUri = null;
if ($includePhoto) {
// Generate filesystem URI
$webDir = $this->kernelRootDir . '/../web/';
$photoUri = $webDir . $profile['photo'];
} else {
// Generate absolute public URI
$photoUri = $this->request->getUriForPath('/' . $profile['photo']);
}
$vcard->addPhoto($photoUri, $includePhoto);
}
return $vcard;
}