Пример #1
0
 private function processNode(\DOMElement $node, \DOMXpath $xpath)
 {
     $title = $node->getAttribute("TEXT");
     $topic = new Topic($title);
     $childNodes = $xpath->query("./node", $node);
     foreach ($childNodes as $childNode) {
         $subTopic = $this->processNode($childNode, $xpath);
         $topic->addSub($subTopic);
     }
     return $topic;
 }
Пример #2
0
 public function testSimpleMap()
 {
     $created = "143513451";
     $rootTopic = new Topic("Central", $created);
     $subTopicA = new Topic("A", $created);
     $subTopicB = new Topic("B", $created);
     $rootTopic->addSub($subTopicA);
     $rootTopic->addSub($subTopicB);
     $doc = new Document("Document1", $rootTopic, $created);
     $json = (new Exporter())->export($doc);
     //file_put_contents(__DIR__."/Fixture/expected.json", $json);
     $this->assertJsonStringEqualsJsonFile(__DIR__ . "/Fixture/expected.json", $json);
 }
Пример #3
0
 private function exportTopic(Topic $topic)
 {
     $jsonDoc = new \stdClass();
     $jsonDoc->title = $topic->getTitle();
     $jsonDoc->id = $this->generateId("T", $topic->getCreated());
     $jsonDoc->timestamp = $topic->getCreated();
     $jsonDoc->collapsed = self::DEFAULT_COLLAPSED;
     $jsonDoc->image = self::NOT_DEFINED;
     $jsonDoc->hyperlink = self::NOT_DEFINED;
     $jsonDoc->image = self::NOT_DEFINED;
     $jsonDoc->type = self::DEFAULT_TYPE;
     $jsonDoc->markers = new \stdClass();
     $jsonDoc->style = $this->exportStyle($topic->getStyle());
     $jsonDoc->subtopics = [];
     foreach ($topic->getSubTopics() as $subTopic) {
         $jsonDoc->subtopics[] = $this->exportTopic($subTopic);
     }
     return $jsonDoc;
 }