GeezerVison is showing github.com — Merge pull request #24 from contentstack/feature/json-rte · contentstack/contentstack-php@c8e9be2
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: src/Contentstack.php +10Lines changed: 10 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -60,4 +60,14 @@ public static function renderContents(array $contents, Option $option): array |
60 | 60 | { |
61 | 61 | return Utils::renderContents($contents, $option); |
62 | 62 | } |
| 63 | + |
| 64 | + public static function jsonToHtml(object $content, Option $option): string |
| 65 | + { |
| 66 | + return Utils::jsonToHtml($content, $option); |
| 67 | + } |
| 68 | + |
| 69 | + public static function jsonArrayToHtml(array $contents, Option $option): array |
| 70 | + { |
| 71 | + return Utils::jsonArrayToHtml($contents, $option); |
| 72 | + } |
63 | 73 | } |
Collapse file
Copy file name to clipboardExpand all lines: test/EntriesTest.php +5Lines changed: 5 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -33,6 +33,11 @@ public static function tearDownAfterClass() : void { |
33 | 33 | } |
34 | 34 | } |
35 | 35 |
|
| 36 | + public function testJsonRTE () { |
| 37 | + $jsonObject = json_decode('{ "uid":"0d7fd", "_version":13, "attrs":{ }, "children":[{"type":"p","attrs":{},"uid":"0a1b5676aa510e5a","children":[{"text":"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem."}]}],"type":"doc"}'); |
| 38 | + $result = Contentstack::jsonToHtml($jsonObject, new Option()); |
| 39 | + $this->assertEquals('<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed condimentum iaculis magna in vehicula. Vestibulum vitae convallis lacus. Praesent a diam iaculis turpis rhoncus faucibus. Aliquam sed pulvinar sem.</p>', $result); |
| 40 | + } |
36 | 41 | public function testFind() { |
37 | 42 | $_entries = self::$Stack->ContentType(CT_ContentType)->Query()->toJSON()->find(); |
38 | 43 | $this->assertArrayHasKey(0, $_entries); |
|