GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • src
    • Contentstack.php
  • test
    • EntriesTest.php
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/Contentstack.php‎

Copy file name to clipboardExpand all lines: src/Contentstack.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,14 @@ public static function renderContents(array $contents, Option $option): array
6060
{
6161
return Utils::renderContents($contents, $option);
6262
}
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+
}
6373
}
Collapse file

‎test/EntriesTest.php‎

Copy file name to clipboardExpand all lines: test/EntriesTest.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public static function tearDownAfterClass() : void {
3333
}
3434
}
3535

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+
}
3641
public function testFind() {
3742
$_entries = self::$Stack->ContentType(CT_ContentType)->Query()->toJSON()->find();
3843
$this->assertArrayHasKey(0, $_entries);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.