netglue / prismic-php-kit

Unofficial Prismic.io PHP SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extract Serialization into a Replaceable Helper

gsteel opened this issue · comments

Because HTML serialisation is subjective, the asHtml() and asText methods in the fragments are just weird.

The lib should ship with a default serialisation implementation that can be easily replaced, so that instead of calling RichText::asHtml() and remembering where to put a link resolver, or having it injected "magically" or whatever, we should have an "HTML Serialiser" thus: $serialiser->serialise($richTextFragment);

I think that the serialiser implementation should be invokable and that __invoke(FragmentInterface $fragment) : string should be defined.