-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return vCard exactly from storage if we don't need to convert.
Fixes #834.
- Loading branch information
Showing
3 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -803,33 +803,49 @@ protected function negotiateVCard($input, &$mimeType = null) { | |
/** | ||
* Converts a vcard blob to a different version, or jcard. | ||
* | ||
* @param string $data | ||
* @param string|resource $data | ||
* @param string $target | ||
* @return string | ||
*/ | ||
protected function convertVCard($data, $target) { | ||
|
||
$data = VObject\Reader::read($data); | ||
switch ($target) { | ||
default : | ||
case 'vcard3' : | ||
$data = $data->convert(VObject\Document::VCARD30); | ||
$newResult = $data->serialize(); | ||
break; | ||
case 'vcard4' : | ||
$data = $data->convert(VObject\Document::VCARD40); | ||
$newResult = $data->serialize(); | ||
break; | ||
case 'jcard' : | ||
$data = $data->convert(VObject\Document::VCARD40); | ||
$newResult = json_encode($data->jsonSerialize()); | ||
break; | ||
|
||
if (is_resource($data)) { | ||
$data = stream_get_contents($data); | ||
} | ||
// Destroy circular references to PHP will GC the object. | ||
$data->destroy(); | ||
$input = VObject\Reader::read($data); | ||
$output = null; | ||
try { | ||
|
||
return $newResult; | ||
switch ($target) { | ||
default : | ||
case 'vcard3' : | ||
if ($input->getDocumentType() === VObject\Document::VCARD30) { | ||
// Do nothing | ||
return $data; | ||
} | ||
$output = $input->convert(VObject\Document::VCARD30); | ||
return $output->serialize(); | ||
case 'vcard4' : | ||
if ($input->getDocumentType() === VObject\Document::VCARD40) { | ||
// Do nothing | ||
return $data; | ||
} | ||
$output = $input->convert(VObject\Document::VCARD40); | ||
return $output->serialize(); | ||
case 'jcard' : | ||
$output = $input->convert(VObject\Document::VCARD40); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
evert
Author
Member
|
||
return json_encode($output); | ||
|
||
} | ||
|
||
} finally { | ||
|
||
// Destroy circular references to PHP will GC the object. | ||
$input->destroy(); | ||
if (!is_null($output)) { | ||
$output->destroy(); | ||
} | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Is this the right constant for jcard?