for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Riclep\Storyblok\Traits;
use Storyblok\RichtextRender\Resolver;
trait ConvertsRichtext
{
protected $richtext = [];
/**
* Takes all the fields in $richtext and applies the Storyblok
* richtext transformer to them. Returns a duplicate field
* suffixed with _html
*/
public function initConvertsRichtext() {
if (!empty($this->richtext)) {
$richtextResolver = new Resolver();
foreach ($this->richtext as $richtextField) {
if ($this->content->has($richtextField)) {
$this->content[$richtextField . '_html'] = $richtextResolver->render($this->content[$richtextField]);
content
}