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

feat: allow any type of processor classes #50

Merged
merged 1 commit into from
Dec 21, 2023
Merged
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
2 changes: 2 additions & 0 deletions doc/01_Doc_Types_and_Available_Processors.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ This bundle introduces 2 new document types:
| [PDF Reactor](https://www.pdfreactor.com/) | A REST/SOAP solution, please visit the official website for further information |

> For details on how to install and configure these processors, please see [Additional Tools Installation](https://pimcore.com/docs/platform/Pimcore/Installation_and_Upgrade/System_Setup_and_Hosting/Additional_Tools_Installation) page in the Core.

You can also add your own Processors as long as they extend the abstract Pimcore\Bundle\WebToPrintBundle\Processor class. Set the full class name in the web2print settings, for example "App\Web2Print\Processor\WkHtmlToPdf".
2 changes: 1 addition & 1 deletion public/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ pimcore.bundle.web2print.settings = Class.create({
fieldLabel: t("web2print_tool"),
xtype: "combo",
width: 600,
editable: false,
editable: true,
name: "generalTool",
value: this.getValue("generalTool"),
store: [
Expand Down
25 changes: 19 additions & 6 deletions src/Processor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,25 @@ public static function getInstance(): PdfReactor|Gotenberg|Chromium|Processor
{
$config = Config::getWeb2PrintConfig();

return match ($config['generalTool']) {
'pdfreactor' => new PdfReactor(),
'chromium' => new Chromium(),
'gotenberg' => new Gotenberg(),
default => throw new \Exception('Invalid Configuration - ' . $config['generalTool'])
};
if($config['generalTool'] == 'pdfreactor'){
return new PdfReactor();
}
elseif($config['generalTool'] == 'chromium'){
return new Chromium();
}
elseif($config['generalTool'] == 'gotenberg'){
return new Gotenberg();
}
else{
kingjia90 marked this conversation as resolved.
Show resolved Hide resolved
if(class_exists($config['generalTool'])){
$generalToolClass = new $config['generalTool']();
if($generalToolClass instanceof Processor){
return $generalToolClass;
}
}
}

throw new \Exception('Invalid Configuration - ' . $config['generalTool']);
}

/**
Expand Down
Loading