php-JiraCloud-RESTAPI icon indicating copy to clipboard operation
php-JiraCloud-RESTAPI copied to clipboard

How to convert ADF description to normal text/html?

Open bertoost opened this issue 2 years ago • 2 comments

Hi

First of all, great to see the package is updated for v3 and php8+. Works like a charm!

Therefore, the ADF is nice, but I am using the API to sync issue titles and descriptions and I can't get this html export to convert a AtlassianDocumentFormat to a Document, which the exportor is requiring.

if ($description instanceof AtlassianDocumentFormat) {
    $doc = /* how to? */;
    $exporter = new DocumentExporter($doc);
    $description = $exporter->export();
}

I have tried this;

$doc = Document::load($description);
// or
$doc = Document::load((array) $description);
// or
$doc = Document::load($description->jsonSerialize());

but all with no luck.. I don't know.. can you help me out?

Regards, Bert

bertoost avatar Apr 06 '23 20:04 bertoost

FYI; I able to convert it this way; but I can imagine it should be easier to achieve;

$doc = Document::load(['type' => $description->type[0], 'content' => json_decode(json_encode($description->content), true)]);

bertoost avatar Apr 06 '23 20:04 bertoost

Hi @bertoost Thank you for reaching out to me. I'll investigate it this week. Thanks!

lesstif avatar Apr 16 '23 16:04 lesstif