mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-07-16 13:55:21 +00:00
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.
66 lines
2.5 KiB
PHP
66 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Providers;
|
|
|
|
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;
|
|
|
|
class DriverRegistryProvider extends ServiceProvider
|
|
{
|
|
public function boot(): void
|
|
{
|
|
$this->registerExchangeRateDrivers();
|
|
}
|
|
|
|
protected function registerExchangeRateDrivers(): void
|
|
{
|
|
Registry::registerExchangeRateDriver('currency_converter', [
|
|
'class' => CurrencyConverterDriver::class,
|
|
'label' => 'settings.exchange_rate.currency_converter',
|
|
'website' => 'https://www.currencyconverterapi.com',
|
|
'config_fields' => [
|
|
[
|
|
'key' => 'type',
|
|
'type' => 'select',
|
|
'label' => 'settings.exchange_rate.server',
|
|
'options' => [
|
|
['label' => 'settings.preferences.premium', 'value' => 'PREMIUM'],
|
|
['label' => 'settings.preferences.prepaid', 'value' => 'PREPAID'],
|
|
['label' => 'settings.preferences.free', 'value' => 'FREE'],
|
|
['label' => 'settings.preferences.dedicated', 'value' => 'DEDICATED'],
|
|
],
|
|
'default' => 'FREE',
|
|
],
|
|
[
|
|
'key' => 'url',
|
|
'type' => 'text',
|
|
'label' => 'settings.exchange_rate.url',
|
|
'visible_when' => ['type' => 'DEDICATED'],
|
|
],
|
|
],
|
|
]);
|
|
|
|
Registry::registerExchangeRateDriver('currency_freak', [
|
|
'class' => CurrencyFreakDriver::class,
|
|
'label' => 'settings.exchange_rate.currency_freak',
|
|
'website' => 'https://currencyfreaks.com',
|
|
]);
|
|
|
|
Registry::registerExchangeRateDriver('currency_layer', [
|
|
'class' => CurrencyLayerDriver::class,
|
|
'label' => 'settings.exchange_rate.currency_layer',
|
|
'website' => 'https://currencylayer.com',
|
|
]);
|
|
|
|
Registry::registerExchangeRateDriver('open_exchange_rate', [
|
|
'class' => OpenExchangeRateDriver::class,
|
|
'label' => 'settings.exchange_rate.open_exchange_rate',
|
|
'website' => 'https://openexchangerates.org',
|
|
]);
|
|
}
|
|
}
|