/** * @param $url * @param array $arguments * @param string $uniqueId * * @throws \Exception * * @return string */ public function rasterizeUrl($url, $arguments = array(), $uniqueId = "") { if ($uniqueId === "") { $uniqueId = uniqid("rasterize-"); } if ($this->stopwatch instanceof Stopwatch) { if ($this->stopwatch->isStarted($uniqueId)) { $this->stopwatch->lap($uniqueId); } else { $this->stopwatch->start($uniqueId); } } $process = $this->configHelper->buildProcess($url, $uniqueId, $arguments); $exitCode = $process->run(); if ($exitCode != 0) { throw new \Exception(sprintf("Rasterize script failed.\nCommandLine: %s\nExitCode: %d\nErrorOutput: %s", $process->getCommandLine(), $process->getExitCode(), $process->getErrorOutput())); } if ($this->stopwatch instanceof Stopwatch) { $this->stopwatch->stop($uniqueId); } $output = $this->configHelper->getOutputFilePath($uniqueId); $content = file_get_contents($output); unlink($output); return $content; }
/** * @test */ public function isOutputFilePathCorrect() { $this->assertEquals($this->normalizePath($this->rootDir . '/../web/bundles/padam87rasterize/temp' . DIRECTORY_SEPARATOR . 'e4e5k2.' . $this->config['arguments']['format']), $this->normalizePath($this->configHelper->getOutputFilePath('e4e5k2'))); }