contentful / rich-text.php

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

The default renderers are not forwarding the context #53

Closed matthewhaworth closed 4 years ago

matthewhaworth commented 4 years ago

Hey!

The default renderers in Contentful\RichText\NodeRenderer\* are not forwarding the context to the render() and renderCollection() calls. For instance, Contentful\RichText\NodeRenderer\Document (which I do not add a version of myself):

 /**
     * {@inheritdoc}
     */
    public function render(RendererInterface $renderer, NodeInterface $node, array $context = []): string
    {
        /* @var NodeClass $node */
        if (!$node instanceof NodeClass) {
            throw new \LogicException(\sprintf('Trying to use node renderer "%s" to render unsupported node of class "%s".', \get_class($this), \get_class($node)));
        }

        return $renderer->renderCollection($node->getContent()); // <-- CONTEXT SHOULD BE SECOND PARAMETER
    }

If I get chance I'll PR this in.

pgrigoruta commented 4 years ago

Thanks @matthewhaworth , we just released version 3.1.1 which fixes the issue.