@@ 109-126 (lines=18) @@ | ||
106 | * @param array $params |
|
107 | * @throws \RuntimeException |
|
108 | */ |
|
109 | public function out(InputInterface $source, $outputFormat, $xsl = null, array $params = array()) |
|
110 | { |
|
111 | if (is_string($xsl)) { |
|
112 | $xsl = new FileInput($xsl); |
|
113 | } |
|
114 | $process = $this->runProcess($source, "-", $outputFormat, $xsl, $params); |
|
115 | $process->run(function ($type, $buffer) { |
|
116 | if (Process::OUT === $type) { |
|
117 | echo $buffer; |
|
118 | } |
|
119 | }); |
|
120 | if (!$process->isSuccessful()) { |
|
121 | $e = new \Exception ( "Apache FOP exception.\n" . $process->getErrorOutput() ); |
|
122 | throw new \RuntimeException ( "Can't generate the document", null, $e ); |
|
123 | } |
|
124 | ||
125 | return true; |
|
126 | } |
|
127 | /** |
|
128 | * Convert reading a FOP input, and flush to output the result |
|
129 | * @param InputInterface $source |
|
@@ 136-153 (lines=18) @@ | ||
133 | * @param array $params |
|
134 | * @throws \RuntimeException |
|
135 | */ |
|
136 | public function callback(InputInterface $source, $callback, $outputFormat, $xsl = null, array $params = array()) |
|
137 | { |
|
138 | if (is_string($xsl)) { |
|
139 | $xsl = new FileInput($xsl); |
|
140 | } |
|
141 | $process = $this->runProcess($source, "-", $outputFormat, $xsl, $params); |
|
142 | $process->run(function ($type, $buffer) { |
|
143 | if (Process::OUT === $type) { |
|
144 | $callback($buffer); |
|
145 | } |
|
146 | }); |
|
147 | if (!$process->isSuccessful()) { |
|
148 | $e = new \Exception ( "Apache FOP exception.\n" . $process->getErrorOutput() ); |
|
149 | throw new \RuntimeException ( "Can't generate the document", null, $e ); |
|
150 | } |
|
151 | ||
152 | return true; |
|
153 | } |
|
154 | ||
155 | /** |
|
156 | * |