1 : <?php
2 :
3 : /**
4 : * XSLT Benchmarking
5 : * @link https://github.com/masicek/XSLT-Benchmarking
6 : * @author Viktor Mašíček <viktor@masicek.net>
7 : * @license "New" BSD License
8 : */
9 :
10 : namespace XSLTBenchmarking\TestsGenerator;
11 :
12 : require_once __DIR__ . '/IXmlGeneratorDriver.php';
13 : require_once ROOT . '/TestsGenerator/Templating/SmartyTemplatingDriver.php';
14 : require_once LIBS . '/PhpPath/PhpPath.min.php';
15 : require_once ROOT . '/Exceptions.php';
16 :
17 : use PhpPath\P;
18 :
19 : /**
20 : * Driver for generating XML files by Smarty.
21 : *
22 : * @author Viktor Mašíček <viktor@masicek.net>
23 : */
24 : class SmartyXmlGeneratorDriver extends SmartyTemplatingDriver implements IXmlGeneratorDriver
25 : {
26 :
27 :
28 : /**
29 : * Object configuration
30 : *
31 : * @param string $tmpDirectory The path of the temporary directory
32 : */
33 : public function __construct($tmpDirectory)
34 : {
35 4 : parent::__construct($tmpDirectory);
36 3 : }
37 :
38 :
39 : /**
40 : * Generate xml file
41 : *
42 : * @param string $outputPath The path of the output xml file
43 : * @param array $settings The list of settings specific by selected xml generator
44 : *
45 : * @return void
46 : */
47 : public function generate($outputPath, $templateDir, array $settings)
48 : {
49 : try
50 : {
51 3 : $templatePath = P::m($templateDir, $settings['template']);
52 3 : parent::generate($templatePath, $outputPath, $settings);
53 : }
54 3 : catch (\XSLTBenchmarking\GenerateTemplateException $e)
55 : {
56 1 : throw new \XSLTBenchmarking\GenerateXmlException($e->getMessage());
57 : }
58 1 : }
59 :
60 :
61 : }
|