Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fix no result #88

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ public static function getInstance(): PdfReactor|Gotenberg|Chromium|Processor
{
$config = Config::getWeb2PrintConfig();

if($config['generalTool'] == 'pdfreactor') {
if ($config['generalTool'] == 'pdfreactor') {
return new PdfReactor();
} elseif($config['generalTool'] == 'chromium') {
} elseif ($config['generalTool'] == 'chromium') {
return new Chromium();
} elseif($config['generalTool'] == 'gotenberg') {
} elseif ($config['generalTool'] == 'gotenberg') {
return new Gotenberg();
} else {
if(class_exists($config['generalTool'])) {
if (class_exists($config['generalTool'])) {
$generalToolClass = new $config['generalTool']();
if($generalToolClass instanceof Processor) {
if ($generalToolClass instanceof Processor) {
return $generalToolClass;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/Processor/Api/PDFreactor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public function convert($config, & $connectionSettings = null)
}
}
}
if (!$result) {
throw $this->_createServerException('serviceUnavailable', 'PDFreactor Web Service is unavailable.', $result);
}
if ($status == 422) {
throw $this->_createServerException($errorId, $result->error, $result);
} elseif ($status == 400) {
Expand Down
11 changes: 10 additions & 1 deletion tests/Model/Processor/ProcessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace Pimcore\Bundle\WebToPrintBundle\Tests\Model\Processor;

use com\realobjects\pdfreactor\webservice\client\ServiceUnavailableException;
use Pimcore\Bundle\WebToPrintBundle\Config;
use Pimcore\Bundle\WebToPrintBundle\Processor;
use Pimcore\Document\Adapter\Ghostscript;
Expand Down Expand Up @@ -68,7 +69,12 @@ public function checkProcessors(string $processorName, array $config): void

$processorClass = 'Pimcore\Bundle\WebToPrintBundle\Processor\\'.$processorName;
$processor = new $processorClass();
$pdfContent = $this->getPDFfromProcessor($processor, $config);

try {
$pdfContent = $this->getPDFfromProcessor($processor, $config);
} catch (ServiceUnavailableException $e) {
$this->markTestIncomplete('Service Unavailable: ' . $e->getMessage());
}

$file = tmpfile();
$tempMetadata = stream_get_meta_data($file);
Expand All @@ -91,6 +97,9 @@ public function checkProcessors(string $processorName, array $config): void

}

/**
* @throws ServiceUnavailableException
*/
private function getPDFfromProcessor(Processor $processor, array $config): string
{
$html = file_get_contents(__DIR__.'/../../Support/Resources/test_web2print.html.twig');
Expand Down
Loading