refactor(backend) : extract CuidEntityTrait, abstract audit subscriber, merge history controllers
- Extract shared ID generation + timestamps into CuidEntityTrait used by all entities - Create AbstractAuditSubscriber to deduplicate audit logic across 7 subscribers - Merge per-entity history controllers into single EntityHistoryController - Delete redundant ComposantHistory/MachineHistory/PieceHistory/ProductHistoryController - Add OpenApiDecorator for API documentation customization - Disable failOnDeprecation in PHPUnit (vendor API Platform deprecation) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -6,6 +6,8 @@ namespace App\Service;
|
||||
|
||||
class PdfCompressorService
|
||||
{
|
||||
private ?bool $qpdfAvailable = null;
|
||||
|
||||
/**
|
||||
* Compress an actual PDF file on disk. Returns metadata or null if no gain.
|
||||
*
|
||||
@@ -13,8 +15,7 @@ class PdfCompressorService
|
||||
*/
|
||||
public function compressFile(string $absolutePath): ?array
|
||||
{
|
||||
exec('which qpdf', $qpdfPath, $returnCode);
|
||||
if (0 !== $returnCode) {
|
||||
if (!$this->isQpdfAvailable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -65,9 +66,7 @@ class PdfCompressorService
|
||||
|
||||
public function compressBase64Pdf(string $base64Data): ?array
|
||||
{
|
||||
// Check if qpdf is available
|
||||
exec('which qpdf', $qpdfPath, $returnCode);
|
||||
if (0 !== $returnCode) {
|
||||
if (!$this->isQpdfAvailable()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -127,4 +126,14 @@ class PdfCompressorService
|
||||
'saved' => $originalSize - $compressedSize,
|
||||
];
|
||||
}
|
||||
|
||||
private function isQpdfAvailable(): bool
|
||||
{
|
||||
if (null === $this->qpdfAvailable) {
|
||||
exec('which qpdf', $qpdfPath, $returnCode);
|
||||
$this->qpdfAvailable = 0 === $returnCode;
|
||||
}
|
||||
|
||||
return $this->qpdfAvailable;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user