Ejemplo n.º 1
0
 /**
  *
  * @param \sufir\PlantUml\Diagram\ADiagram $diagram
  * @return string
  */
 public function convertDiagram(ADiagram $diagram)
 {
     $uml = $diagram->render();
     $jar = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'bin' . DIRECTORY_SEPARATOR . 'plantuml.jar';
     if (!file_exists($jar)) {
         throw new \InvalidArgumentException('plantuml.jar not found: ' . $jar);
     }
     $outputFormat = $this->outputFormat === PlantUml::OUTPUT_FORMAT_SVG ? '-tsvg' : '';
     $tmpInputFile = tempnam(sys_get_temp_dir(), 'plantuml');
     file_put_contents($tmpInputFile, $uml);
     $tmpOutputFile = tempnam(sys_get_temp_dir(), 'image');
     if (stristr(PHP_OS, 'WIN')) {
         shell_exec('type "' . $tmpInputFile . '" | java -jar "' . $jar . '" ' . $outputFormat . ' -charset UTF-8 -pipe > "' . $tmpOutputFile . '"');
     } elseif (stristr(PHP_OS, 'LINUX')) {
         shell_exec('cat "' . $tmpInputFile . '" | java -jar "' . $jar . '" ' . $outputFormat . ' -charset UTF-8 -pipe > "' . $tmpOutputFile . '"');
     }
     $result = file_get_contents($tmpOutputFile);
     unlink($tmpInputFile);
     unlink($tmpOutputFile);
     return $result;
 }
Ejemplo n.º 2
0
 public function convertDiagram(ADiagram $diagram)
 {
     return file_get_contents("http://www.plantuml.com:80/plantuml/{$this->outputFormat}/" . $this->encode64(gzdeflate($diagram->render(), 9)));
 }