protected function setupDefaults()
    {
        $this->addTransformer('html', function ($value) {
            return new Markup($value, 'UTF-8');
        });
        $this->addTransformer('text', function ($value) {
            return new Markup($value, 'UTF-8');
        });
        $this->addTransformer('textarea', function ($value) {
            return new Markup($value, 'UTF-8');
        });
        $this->addTransformer('markdown', function ($value) {
            $markdown = new ParsedownExtra();
            $value = $markdown->text($value);

            return new Markup($value, 'UTF-8');
        });

        $this->addTransformer('repeater', function ($value) {
            /** @var FieldCollection $collection */
            foreach ($value as $collection) {
                foreach ($collection as $field) {
                    $field->setValue($this->transform($field->getValue(), $field->getFieldType()));
                }
            }

            return $value;
        });

        $this->addTransformer('block', function ($value) {
            return $this->transform($value, 'repeater');
        });
    }
protected function setupDefaults()
    {
        $this->addTransformer('html', function ($value) {
            return new Markup($value, 'UTF-8');
        });
        $this->addTransformer('text', function ($value) {
            return new Markup($value, 'UTF-8');
        });
        $this->addTransformer('textarea', function ($value) {
            return new Markup($value, 'UTF-8');
        });
        $this->addTransformer('markdown', function ($value) {
            $markdown = new ParsedownExtra();
            $value = $markdown->text($value);

            return new Markup($value, 'UTF-8');
        });

        $this->addTransformer('repeater', function ($value) {
            /** @var FieldCollection $collection */
            foreach ($value as $collection) {
                foreach ($collection as $field) {
                    $field->setValue($this->transform($field->getValue(), $field->getFieldType()));
                }
            }

            return $value;
        });

        $this->addTransformer('block', function ($value) {
            return $this->transform($value, 'repeater');
        });
    }
protected function setupDefaults ( ) { $ this -> addTransformer ( 'html' , function ( $ value ) { return new Markup ( $ value , 'UTF-8' ) ; } ) ; $ this -> addTransformer ( 'text' , function ( $ value ) { return new Markup ( $ value , 'UTF-8' ) ; } ) ; $ this -> addTransformer ( 'textarea' , function ( $ value ) { return new Markup ( $ value , 'UTF-8' ) ; } ) ; $ this -> addTransformer ( 'markdown' , function ( $ value ) { $ markdown = new ParsedownExtra ( ) ; $ value = $ markdown -> text ( $ value ) ; return new Markup ( $ value , 'UTF-8' ) ; } ) ; $ this -> addTransformer ( 'repeater' , function ( $ value ) { /** @var FieldCollection $collection */ foreach ( $ value as $ collection ) { foreach ( $ collection as $ field ) { $ field -> setValue ( $ this -> transform ( $ field -> getValue ( ) , $ field -> getFieldType ( ) ) ) ; } } return $ value ; } ) ; $ this -> addTransformer ( 'block' , function ( $ value ) { return $ this -> transform ( $ value , 'repeater' ) ; } ) ; }
Here we register some transformers that prepare the fields to be passed to
twig. For repeaters and blocks this is recursive.
Here we register some transformers that prepare the fields to be passed to twig . For repeaters and blocks this is recursive .