From 5263c2c9763e3d63be4a9b46db9cc90cb812de6a Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 24 Oct 2024 23:24:21 +0200 Subject: [PATCH] Move types --- .../Resources/MaildispatcherResource.php | 1 - app/Mailgateway/MailgatewaySettings.php | 33 --------- .../Resources/MailgatewayResource.php | 68 ------------------- app/Providers/AppServiceProvider.php | 8 --- modules/Mailgateway/Components/Form.php | 2 +- modules/Mailgateway/IndexTest.php | 2 +- .../MailgatewayServiceProvider.php | 7 ++ modules/Mailgateway/Models/Mailgateway.php | 2 +- .../Mailgateway/Models/MailgatewayFactory.php | 4 +- modules/Mailgateway/StoreTest.php | 4 +- .../Mailgateway/Types/LocalType.php | 2 +- .../Mailgateway/Types/MailmanType.php | 2 +- {app => modules}/Mailgateway/Types/Type.php | 2 +- modules/Mailgateway/UpdateTest.php | 4 +- tests/EndToEnd/Maildispatcher/StoreTest.php | 2 +- tests/EndToEnd/Maildispatcher/UpdateTest.php | 3 +- tests/RequestFactories/MailmanTypeRequest.php | 2 +- 17 files changed, 22 insertions(+), 126 deletions(-) delete mode 100644 app/Mailgateway/MailgatewaySettings.php delete mode 100644 app/Mailgateway/Resources/MailgatewayResource.php rename {app => modules}/Mailgateway/Types/LocalType.php (97%) rename {app => modules}/Mailgateway/Types/MailmanType.php (99%) rename {app => modules}/Mailgateway/Types/Type.php (98%) diff --git a/app/Maildispatcher/Resources/MaildispatcherResource.php b/app/Maildispatcher/Resources/MaildispatcherResource.php index 9928209e..90c97640 100644 --- a/app/Maildispatcher/Resources/MaildispatcherResource.php +++ b/app/Maildispatcher/Resources/MaildispatcherResource.php @@ -5,7 +5,6 @@ namespace App\Maildispatcher\Resources; use App\Lib\HasMeta; use App\Maildispatcher\Models\Maildispatcher; use Modules\Mailgateway\Models\Mailgateway; -use App\Mailgateway\Resources\MailgatewayResource; use App\Member\FilterScope; use App\Member\Member; use Illuminate\Http\Resources\Json\JsonResource; diff --git a/app/Mailgateway/MailgatewaySettings.php b/app/Mailgateway/MailgatewaySettings.php deleted file mode 100644 index 31c38d57..00000000 --- a/app/Mailgateway/MailgatewaySettings.php +++ /dev/null @@ -1,33 +0,0 @@ - MailgatewayResource::collection(Mailgateway::paginate(10)), - ]; - } -} diff --git a/app/Mailgateway/Resources/MailgatewayResource.php b/app/Mailgateway/Resources/MailgatewayResource.php deleted file mode 100644 index 3386d35a..00000000 --- a/app/Mailgateway/Resources/MailgatewayResource.php +++ /dev/null @@ -1,68 +0,0 @@ - - */ - public function toArray($request) - { - return [ - 'name' => $this->name, - 'domain' => $this->domain, - 'type_human' => $this->type::name(), - 'works' => $this->type->works(), - 'id' => $this->id, - 'links' => [ - 'update' => route('mailgateway.update', ['mailgateway' => $this->getModel()]), - ], - ]; - } - - /** - * @return array - */ - public static function meta(): array - { - return [ - 'links' => [ - 'store' => route('mailgateway.store'), - ], - 'types' => app('mail-gateways')->map(fn ($gateway) => [ - 'id' => $gateway, - 'name' => $gateway::name(), - 'fields' => $gateway::presentFields('storeValidator'), - 'defaults' => (object) $gateway::defaults(), - ])->prepend([ - 'id' => null, - 'name' => '-- kein --', - 'fields' => [], - 'defaults' => (object) [], - ]), - 'default' => [ - 'domain' => '', - 'name' => '', - 'type' => [ - 'params' => [], - 'cls' => null, - ], - ], - ]; - } -} diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index 27fca8a7..7fd14fe9 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -3,13 +3,10 @@ namespace App\Providers; use App\Form\Models\Form; -use App\Mailgateway\Types\LocalType; -use App\Mailgateway\Types\MailmanType; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Support\Facades\Blade; use Illuminate\Support\ServiceProvider; -use Laravel\Telescope\Telescope; class AppServiceProvider extends ServiceProvider { @@ -30,11 +27,6 @@ class AppServiceProvider extends ServiceProvider return $this; }); - app()->bind('mail-gateways', fn () => collect([ - LocalType::class, - MailmanType::class, - ])); - app()->extend('media-library-helpers', fn ($p) => $p->put('form', Form::class)); Blade::componentNamespace('App\\View\\Mail', 'mail-view'); diff --git a/modules/Mailgateway/Components/Form.php b/modules/Mailgateway/Components/Form.php index ce1f4390..289d374d 100644 --- a/modules/Mailgateway/Components/Form.php +++ b/modules/Mailgateway/Components/Form.php @@ -3,7 +3,7 @@ namespace Modules\Mailgateway\Components; use Modules\Mailgateway\Models\Mailgateway; -use App\Mailgateway\Types\Type; +use Modules\Mailgateway\Types\Type; use Illuminate\Support\Collection; use Illuminate\Validation\ValidationException; use Livewire\Attributes\On; diff --git a/modules/Mailgateway/IndexTest.php b/modules/Mailgateway/IndexTest.php index b0e018e7..1d86d2e5 100644 --- a/modules/Mailgateway/IndexTest.php +++ b/modules/Mailgateway/IndexTest.php @@ -3,7 +3,7 @@ namespace Modules\Mailgateway; use Modules\Mailgateway\Models\Mailgateway; -use App\Mailgateway\Types\LocalType; +use Modules\Mailgateway\Types\LocalType; use Illuminate\Foundation\Testing\DatabaseTransactions; use Livewire\Livewire; use Modules\Mailgateway\Components\SettingView; diff --git a/modules/Mailgateway/MailgatewayServiceProvider.php b/modules/Mailgateway/MailgatewayServiceProvider.php index f0f2b64a..28d21e5b 100644 --- a/modules/Mailgateway/MailgatewayServiceProvider.php +++ b/modules/Mailgateway/MailgatewayServiceProvider.php @@ -7,6 +7,8 @@ use Illuminate\Routing\Router; use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; use Modules\Mailgateway\Components\SettingView; +use Modules\Mailgateway\Types\LocalType; +use Modules\Mailgateway\Types\MailmanType; class MailgatewayServiceProvider extends ServiceProvider { @@ -32,6 +34,11 @@ class MailgatewayServiceProvider extends ServiceProvider $router->get('/setting/mailgateway', SettingView::class)->name('setting.mailgateway'); }); + app()->bind('mail-gateways', fn () => collect([ + LocalType::class, + MailmanType::class, + ])); + View::addNamespace('mailgateway', __DIR__ . '/Components'); } } diff --git a/modules/Mailgateway/Models/Mailgateway.php b/modules/Mailgateway/Models/Mailgateway.php index 5e39798a..dd401106 100644 --- a/modules/Mailgateway/Models/Mailgateway.php +++ b/modules/Mailgateway/Models/Mailgateway.php @@ -2,7 +2,7 @@ namespace Modules\Mailgateway\Models; -use App\Mailgateway\Types\Type; +use Modules\Mailgateway\Types\Type; use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; diff --git a/modules/Mailgateway/Models/MailgatewayFactory.php b/modules/Mailgateway/Models/MailgatewayFactory.php index 3f97c29c..1f58409f 100644 --- a/modules/Mailgateway/Models/MailgatewayFactory.php +++ b/modules/Mailgateway/Models/MailgatewayFactory.php @@ -2,8 +2,8 @@ namespace Modules\Mailgateway\Models; -use App\Mailgateway\Types\LocalType; -use App\Mailgateway\Types\Type; +use Modules\Mailgateway\Types\Type; +use Modules\Mailgateway\Types\LocalType; use Illuminate\Database\Eloquent\Factories\Factory; /** diff --git a/modules/Mailgateway/StoreTest.php b/modules/Mailgateway/StoreTest.php index debb6dfb..dbb04d32 100644 --- a/modules/Mailgateway/StoreTest.php +++ b/modules/Mailgateway/StoreTest.php @@ -2,11 +2,11 @@ namespace Modules\Mailgateway; -use App\Mailgateway\Types\LocalType; -use App\Mailgateway\Types\MailmanType; use Illuminate\Foundation\Testing\DatabaseTransactions; use Livewire\Livewire; use Modules\Mailgateway\Components\Form; +use Modules\Mailgateway\Types\LocalType; +use Modules\Mailgateway\Types\MailmanType; use Tests\RequestFactories\MailmanTypeRequest; use Tests\TestCase; diff --git a/app/Mailgateway/Types/LocalType.php b/modules/Mailgateway/Types/LocalType.php similarity index 97% rename from app/Mailgateway/Types/LocalType.php rename to modules/Mailgateway/Types/LocalType.php index 81d3f60c..fa3f5231 100644 --- a/app/Mailgateway/Types/LocalType.php +++ b/modules/Mailgateway/Types/LocalType.php @@ -1,6 +1,6 @@