According to RFC 6350, section 5.9, the SORT-AS parameter in a vCard-4.0 looks something like this:
N;SORT-AS="Harten,Rene":van der Harten;Rene,J.;Sir;R.D.O.N.
Let's try to replicate this example in Sabre-VObject 3.0.0-alpha4:
<?php
include('lib/SabreDAV/vendor/autoload.php');
use Sabre\VObject;
$card = new VObject\Component\VCard();
$card->add('N', array('van der Harten', array('Rene','J.'),'Sir','R.D.O.N.'), array('SORT-AS' => array('Harten','Rene')));
echo $card->serialize();
PHP spews a warning:
Warning: strtr() expects parameter 1 to be string, array given in (filename)
Sabre-VObject does not allow us to set multiple values per name component as specified in RFC 2426. Alright, try plain strings instead:
<?php
include('lib/SabreDAV/vendor/autoload.php');
use Sabre\VObject;
$card = new VObject\Component\VCard();
$card->add('N', array('van der Harten','Rene,J.','Sir','R.D.O.N.'), array('SORT-AS' => 'Harten,Rene'));
echo $card->serialize();
Output:
BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 3.0.0-alpha4//EN
N;SORT-AS=Harten,Rene:van der Harten;Rene\,J.;Sir;R.D.O.N.
END:VCARD
Inconsistency: the comma in the property value is escaped, but not in the parameter value.
According to the RFC, the SORT-AS
value should be surrounded by double quotes. Since Sabre-VObject does not add them for us, let's try to force them by including them in the value:
<?php
include('lib/SabreDAV/vendor/autoload.php');
use Sabre\VObject;
$card = new VObject\Component\VCard();
$card->add('N', array('van der Harten','Rene,J.','Sir','R.D.O.N.'), array('SORT-AS' => '"Harten,Rene"'));
echo $card->serialize();
The output, not surprisingly, escapes the double quotes:
BEGIN:VCARD
VERSION:3.0
PRODID:-//Sabre//Sabre VObject 3.0.0-alpha4//EN
N;SORT-AS="^'Harten,Rene^'":van der Harten;Rene\,J.;Sir;R.D.O.N.
END:VCARD
And so it seems impossible to generate the SORT-AS parameter with escaped components and unescaped double quotes like the canonical example in the RFC.