10 use Mustache_Loader_FilesystemLoader;
22 private $mustacheEngine;
29 private $operationName;
36 private $operationDataType;
43 private $operationUrl;
68 public function __construct($operationName, $operationDataType, $operationUrl, $inputString)
70 $this->operationName = $operationName;
71 $this->operationDataType = $operationDataType;
72 $this->operationUrl = $operationUrl;
73 $this->inputString = $inputString;
75 $this->filepath = self::OUTPUT_DIR . DIRECTORY_SEPARATOR . $this->operationDataType .
"-meta.xml";
87 $this->mustacheEngine =
new Mustache_Engine(
88 [
'loader' =>
new Mustache_Loader_FilesystemLoader(
"views"),
89 'partials_loader' =>
new Mustache_Loader_FilesystemLoader(
90 "views" . DIRECTORY_SEPARATOR .
"partials" 95 parse_str($this->inputString,
$results);
96 $data = $this->convertResultToEntry(
$results, $this->operationDataType);
98 $output = $this->mustacheEngine->render(
'operation',
$data);
99 $this->cleanAndCreateOutputDir();
112 private function appendParentParams(
$data)
115 $result[
'operationName'] = $this->operationName;
116 $result[
'operationDataType'] = $this->operationDataType;
117 $result[
'operationUrl'] = $this->operationUrl;
130 private function convertResultToEntry(
$results, $defaultDataType)
137 $entry = array_merge($entry, [
'objectName' => $key]);
138 $res = $this->convertResultToEntry(
$result, $defaultDataType);
139 if (!array_key_exists(
'objects', $res)) {
140 $entry = array_merge($entry, [
'objects' =>
null]);
141 $entry = array_merge($entry, [
'dataType' => $key]);
143 $entry = array_merge($entry, [
'hasChildObj' =>
true]);
144 $entry = array_merge($entry, [
'dataType' => $defaultDataType]);
146 $data[
'objects'][] = array_merge($entry, $res);
148 $data[
'fields'][] = [
'fieldName' => $key];
160 private function cleanAndCreateOutputDir()
162 if (!file_exists(self::OUTPUT_DIR)) {
163 mkdir(self::OUTPUT_DIR);
166 if (file_exists($this->filepath)) {
mkdir($pathname, $mode=0777, $recursive=false, $context=null)