Skip to content
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

Outdated Doc? Missing LinkResolverInterface #29

Closed
jetwes opened this issue Jan 23, 2019 · 7 comments
Closed

Outdated Doc? Missing LinkResolverInterface #29

jetwes opened this issue Jan 23, 2019 · 7 comments

Comments

@jetwes
Copy link

jetwes commented Jan 23, 2019

If i try
$parser = new Contentful\RichText\Parser();
i get a missing linkresolver error. Any updated on how to use the parser in PHP (here laravel)

@dborsatto
Copy link
Contributor

The parser is handled by the Delivery SDK, what are you trying to achieve?

@jetwes
Copy link
Author

jetwes commented Jan 23, 2019

I fetched an entry through the delivery API and try to parse a markdown fiel...

@jetwes
Copy link
Author

jetwes commented Jan 23, 2019

`public function __construct(DeliveryClient $client)
{
$this->client = $client;
}

public function showNews($id)
{
$entry = $this->client->getEntry($id);

    if (!$entry) {
        abort(404);
    }

   //parse the field "inhalt"
   
    return view('static_site',['title' => $entry->getTitel(),'entry' => $entry]);
}`

@dborsatto
Copy link
Contributor

If you're using a recent (v4) version of the SDK, the parsing will be handled for you. When accessing fields from an entry, they will be correctly represented as node objects. You only need to care about the rendering part 🙂

@jetwes
Copy link
Author

jetwes commented Jan 23, 2019

AH! Great. But i can't find it in the docs, correct?
Thank you anyway ;)

@dborsatto
Copy link
Contributor

I can't remember to be honest, I'll have to double-check 😅 you're welcome!

@jetwes
Copy link
Author

jetwes commented Jan 23, 2019

Briliant. That did the trick ;)
$renderer = new \Contentful\RichText\Renderer(); $renderer->render($entry->getInhalt();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants