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

Printing from DocumentController is broken #689

Open
BertalanD opened this issue Jan 9, 2025 · 1 comment
Open

Printing from DocumentController is broken #689

BertalanD opened this issue Jan 9, 2025 · 1 comment

Comments

@BertalanD
Copy link
Member

@sszajbely

The logic in DocumentController::printDocument seems to have been missed in #394, and the function references the now-nonexistent App\Utils\Printer class:

private function printDocument($result, $filename)
{
if (!$result['success']) {
return $result['redirect'];
}
$document = $result['pdf'];
$printer = new Printer($filename, $document, /* $use_free_pages */ true);
return $printer->print();
}

We should factor out the code for checking and deducting print balances and initiating the print job from PrintJobController::store into a function that can be called from backend logic.

@sszajbely
Copy link
Contributor

Sorry about this oversight. I think the PrinterHelper class would be the most suitable with a function like

function tryCreatePrintJob(string $documentPath, bool $doubleSided, <etc.>) PrintJobCreationProcess

where PrintJobCreationProcess is an enum with values like PrintJobCreationProcess::noBalance, PrintJobCreationProcess::errorPrinting or PrintJobCreationProcess::success. Then both the store method of the PrintJobController and the DocumentController can use this function and based on the returned enum value send a message to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants