From 7357b3036d25fbaef58e7f306dda95dc5fce9161 Mon Sep 17 00:00:00 2001 From: Jordan Beattie Date: Thu, 3 Aug 2023 09:32:09 +0100 Subject: [PATCH] Added redactor function --- README.MD | 7 +++++++ src/variables/FakerVariable.php | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/README.MD b/README.MD index c1e09c1..9b16293 100644 --- a/README.MD +++ b/README.MD @@ -180,6 +180,13 @@ craft.faker.navigation(4) craft.faker.navigation(4, true) ``` +## Redactor +Designed to mimic a Redactor field, the function will accept a single string and return a Redactor\FieldData object. + +``` +craft.faker.redactor("A string that can contain HTML") +``` + ## Contact Jordan Beattie
jordan@mission10.co.uk
diff --git a/src/variables/FakerVariable.php b/src/variables/FakerVariable.php index 7535484..9274b61 100644 --- a/src/variables/FakerVariable.php +++ b/src/variables/FakerVariable.php @@ -99,5 +99,13 @@ public function icon($icon = null, $sprite = null, $glyphId = null, $glyphName = { return new Icon($icon, $sprite, $glyphId, $glyphName, $iconSet, $type, $css, $width, $height); } + + public function redactor( $copy ) + { + return $field = new \craft\redactor\FieldData( $copy ); + $field->content = $copy; + $field->charset = "UTF-8"; + return $field; + } }