예제 #1
0
 private function renderSvg($render, $parameters, $format)
 {
     foreach ($parameters as $key => $variable) {
         $render = str_replace(sprintf('{{ %s }}', $key), $variable, $render);
     }
     return Image::createFromString($render, $format);
 }
예제 #2
0
 /**
  * @param string $render
  * @param array $parameters
  * @param string $format
  *
  * @return Image
  */
 private function renderSvg($render, $parameters, $format)
 {
     foreach ($parameters as $key => $variable) {
         $render = str_replace(sprintf('{{ %s }}', $key), $variable, $render);
     }
     try {
         $xml = new SimpleXMLElement($render);
     } catch (\Exception $e) {
         throw new \RuntimeException('Generated string is not a valid XML');
     }
     if ('svg' !== $xml->getName()) {
         throw new \RuntimeException('Generated xml is not a SVG');
     }
     return Image::createFromString($render, $format);
 }