-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Prismic\Dom\RichText::asHtml(): Argument #3 ($htmlSerializer) must be of type ?closure #71
Comments
As I did a deeper investigation how this works then currently although serialiser is implemented there's no way to pass a custom serialiser closure to each element that gets rendered . Would be cool if we could attach a serialiser method inside our own block or inject it within our templates |
Hi @speedupmate thanks for bringing this up, the SDK is not that pluggable as Magento is... By default, Prismic uses a custom labels concept... Back to a custom serializer and the implementation in Prismic. This is possible, but needs some extra work! tbd (will update this message) |
I finally see the error... duh |
I've updated https://github.com/elgentos/prismicio-php-kit/blob/master/src/Prismic/Dom/RichText.php#L46 This now only accepts a closure... I will add a Many thanks for bringing this up, this is a bug I created :) |
To use a custom serializer in Magento you can create a plugin on function afterSerialize (null $result, \Prismic\Fragment\BlockInterface $object, string $content)
{
if ($object->type === 'heading1') {
return '<h1 class="awesome">' . $content . '</h1>';
}
return $result;
}
If a custom serializer does not return |
Again, sorry I broke it! |
Actually you could just shortcut this to block scope and add getHtmlSerializer() type of reference on method and that would allow to just override any custom-type directly in template level where you work with the custom-type and donät have to detect it extra as you would in plugin : magento2-prismicio/Block/Dom/RichText.php Line 41 in 9e81a94
you could
and then just in some template or block without the complexity of a plugin
|
Thanks |
Seems like it fails to display rich-text fields defined in prismic content types due prismic-sdk now requiring a closure instead of array
The text was updated successfully, but these errors were encountered: