refactor(services): split driver infrastructure out of Services into Support

Services/Integrations/ExchangeRate/ and Services/Pdf/ were both mostly Support-shaped: interfaces, abstract classes, static factories, concrete adapter drivers, DTOs, and exceptions — infrastructure that doesn't carry business logic. They only each had one real DI-injected service mixed in.

This commit applies the same Services=DI-business-logic / Support=stateless-plumbing rule we've been using throughout the reorg:

**Moved to Support/Integrations/ExchangeRate/** (7 files): ExchangeRateDriver (abstract), ExchangeRateDriverFactory (static), ExchangeRateException, and the four concrete drivers (CurrencyConverter, CurrencyFreak, CurrencyLayer, OpenExchangeRate). These are HTTP adapters over third-party currency APIs — same shape as the Hashids library wrapper classes already in Support.

**Moved to Support/Pdf/** (6 files, merging with existing Pdf utilities): PdfDriver (interface), PdfDriverFactory (static), PdfService (static facade), GotenbergPdfDriver, GotenbergPdfResponse (DTO), ResponseStream (interface). The Support/Pdf/ dir now contains the full PDF rendering subsystem — drivers + sanitizer + template/image utilities.

**Promoted to Services/ root** (the real DI services): ExchangeRateProviderService (CRUD for ExchangeRateProvider model) and FontService (font package install/download orchestration). Both are proper DI services — instance methods, model writes, HTTP side effects.

Services/Integrations/ and Services/Pdf/ are now empty and deleted. Services/ holds only DI-injected classes; Support/ holds all the plumbing.

17 files renamed (git detects 90-99% similarity), 4 consumer files updated (DriverRegistryProvider, PdfServiceProvider, ExchangeRateProviderController, FontController, GeneratesPdfTrait, test). 350 tests pass, Pint clean.
This commit is contained in:
Darko Gjorgjijoski
2026-04-11 16:30:00 +02:00
parent 4c3d809f89
commit f657b53215
21 changed files with 28 additions and 28 deletions

View File

@@ -3,7 +3,7 @@
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Services\Pdf\FontService;
use App\Services\FontService;
use Illuminate\Http\JsonResponse;
class FontController extends Controller

View File

@@ -14,7 +14,7 @@ use App\Models\ExchangeRateProvider;
use App\Models\Invoice;
use App\Models\Payment;
use App\Models\Tax;
use App\Services\Integrations\ExchangeRate\ExchangeRateProviderService;
use App\Services\ExchangeRateProviderService;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Support\Arr;

View File

@@ -2,10 +2,10 @@
namespace App\Providers;
use App\Services\Integrations\ExchangeRate\CurrencyConverterDriver;
use App\Services\Integrations\ExchangeRate\CurrencyFreakDriver;
use App\Services\Integrations\ExchangeRate\CurrencyLayerDriver;
use App\Services\Integrations\ExchangeRate\OpenExchangeRateDriver;
use App\Support\Integrations\ExchangeRate\CurrencyConverterDriver;
use App\Support\Integrations\ExchangeRate\CurrencyFreakDriver;
use App\Support\Integrations\ExchangeRate\CurrencyLayerDriver;
use App\Support\Integrations\ExchangeRate\OpenExchangeRateDriver;
use Illuminate\Support\ServiceProvider;
use InvoiceShelf\Modules\Registry;

View File

@@ -2,7 +2,7 @@
namespace App\Providers;
use App\Services\Pdf\PdfService;
use App\Support\Pdf\PdfService;
use Illuminate\Support\ServiceProvider;
class PdfServiceProvider extends ServiceProvider

View File

@@ -1,13 +1,13 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Services;
use App\Http\Requests\ExchangeRateProviderRequest;
use App\Models\CompanySetting;
use App\Models\ExchangeRateLog;
use App\Models\ExchangeRateProvider;
use App\Services\Integrations\ExchangeRate\ExchangeRateDriverFactory;
use App\Services\Integrations\ExchangeRate\ExchangeRateException;
use App\Support\Integrations\ExchangeRate\ExchangeRateDriverFactory;
use App\Support\Integrations\ExchangeRate\ExchangeRateException;
class ExchangeRateProviderService
{

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Services;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Http;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
use Illuminate\Support\Facades\Http;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
use Illuminate\Support\Facades\Http;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
use Illuminate\Support\Facades\Http;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
abstract class ExchangeRateDriver
{

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
use InvalidArgumentException;
use InvoiceShelf\Modules\Registry;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
class ExchangeRateException extends \RuntimeException
{

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Integrations\ExchangeRate;
namespace App\Support\Integrations\ExchangeRate;
use Illuminate\Support\Facades\Http;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Support\Pdf;
use Gotenberg\Gotenberg;
use Gotenberg\Stream;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Support\Pdf;
use Illuminate\Http\Response;
use Psr\Http\Message\ResponseInterface;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Support\Pdf;
interface PdfDriver
{

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Support\Pdf;
use App;

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Support\Pdf;
class PdfService
{

View File

@@ -1,6 +1,6 @@
<?php
namespace App\Services\Pdf;
namespace App\Support\Pdf;
use Illuminate\Http\Response;

View File

@@ -6,7 +6,7 @@ use App\Models\Address;
use App\Models\CompanySetting;
use App\Models\FileDisk;
use App\Models\Setting;
use App\Services\Pdf\FontService;
use App\Services\FontService;
use App\Support\Pdf\PdfHtmlSanitizer;
use Carbon\Carbon;
use Illuminate\Support\Facades\App;

View File

@@ -1,8 +1,8 @@
<?php
use App\Services\Integrations\ExchangeRate\CurrencyFreakDriver;
use App\Services\Integrations\ExchangeRate\ExchangeRateDriver;
use App\Services\Integrations\ExchangeRate\ExchangeRateDriverFactory;
use App\Support\Integrations\ExchangeRate\CurrencyFreakDriver;
use App\Support\Integrations\ExchangeRate\ExchangeRateDriver;
use App\Support\Integrations\ExchangeRate\ExchangeRateDriverFactory;
use InvoiceShelf\Modules\Registry;
test('make resolves built-in drivers from the factory map', function () {