contentful / rich-text.php

Utilities for the Contentful Rich Text
https://www.contentful.com
MIT License
12 stars 9 forks source link

EmbeddedAssetBlock JSON doesn't contain asset #61

Closed twhite94 closed 1 year ago

twhite94 commented 2 years ago

The jsonSerialize method on the class Contentful\RichText\Node\EmbeddedAssetBlock looks like this:

/**
 * {@inheritdoc}
 */
public function jsonSerialize(): array
{
    return [
        'nodeType' => self::getType(),
        'data' => [
            'target' => $this->asset->asLink(),
        ],
        'content' => $this->content
    ];
}

The content is empty, but it would be a lot more useful if $this->asset was returned instead. From that, I could access the file's url and other useful meta information

Would you like me to raise a pull request?

Sebb767 commented 1 year ago

This is resolved with v4.0.0 :)

See https://github.com/contentful/rich-text.php/commit/e957a837e58d1b0502b6152005c24cf34b7152f0

benjamingeorge commented 1 year ago

Did this solution actually address what @twhite94 was suggesting? To me, it sounds like he wanted 'content' => $this->asset . But maybe I misunderstood his request.

Sebb767 commented 1 year ago

@benjamingeorge Assuming they have access to the full JSON, this is pretty much equivalent. That being said, I did not want to overwrite content, as this is usually used for the content and not for a reference.