Move types

This commit is contained in:
philipp lang 2024-10-24 23:24:21 +02:00
parent 5ef5e95be8
commit 836a38390f
17 changed files with 22 additions and 126 deletions

View File

@ -5,7 +5,6 @@ namespace App\Maildispatcher\Resources;
use App\Lib\HasMeta; use App\Lib\HasMeta;
use App\Maildispatcher\Models\Maildispatcher; use App\Maildispatcher\Models\Maildispatcher;
use Modules\Mailgateway\Models\Mailgateway; use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Resources\MailgatewayResource;
use App\Member\FilterScope; use App\Member\FilterScope;
use App\Member\Member; use App\Member\Member;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;

View File

@ -1,33 +0,0 @@
<?php
namespace App\Mailgateway;
use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Resources\MailgatewayResource;
use App\Setting\LocalSettings;
/**
* @deprecated
*/
class MailgatewaySettings extends LocalSettings
{
public static function group(): string
{
return 'mailgateway';
}
public static function title(): string
{
return 'E-Mail-Verbindungen';
}
/**
* @inheritdoc
*/
public function viewData(): array
{
return [
'data' => MailgatewayResource::collection(Mailgateway::paginate(10)),
];
}
}

View File

@ -1,68 +0,0 @@
<?php
namespace App\Mailgateway\Resources;
use App\Lib\HasMeta;
use Modules\Mailgateway\Models\Mailgateway;
use Illuminate\Http\Resources\Json\JsonResource;
/**
* @mixin Mailgateway
* @deprecated
*/
class MailgatewayResource extends JsonResource
{
use HasMeta;
/**
* Transform the resource into an array.
*
* @param \Illuminate\Http\Request $request
*
* @return array<string, mixed>
*/
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<string, mixed>
*/
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,
],
],
];
}
}

View File

@ -3,13 +3,10 @@
namespace App\Providers; namespace App\Providers;
use App\Form\Models\Form; use App\Form\Models\Form;
use App\Mailgateway\Types\LocalType;
use App\Mailgateway\Types\MailmanType;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Laravel\Telescope\Telescope;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {
@ -30,11 +27,6 @@ class AppServiceProvider extends ServiceProvider
return $this; return $this;
}); });
app()->bind('mail-gateways', fn () => collect([
LocalType::class,
MailmanType::class,
]));
app()->extend('media-library-helpers', fn ($p) => $p->put('form', Form::class)); app()->extend('media-library-helpers', fn ($p) => $p->put('form', Form::class));
Blade::componentNamespace('App\\View\\Mail', 'mail-view'); Blade::componentNamespace('App\\View\\Mail', 'mail-view');

View File

@ -3,7 +3,7 @@
namespace Modules\Mailgateway\Components; namespace Modules\Mailgateway\Components;
use Modules\Mailgateway\Models\Mailgateway; use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Types\Type; use Modules\Mailgateway\Types\Type;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Illuminate\Validation\ValidationException; use Illuminate\Validation\ValidationException;
use Livewire\Attributes\On; use Livewire\Attributes\On;

View File

@ -3,7 +3,7 @@
namespace Modules\Mailgateway; namespace Modules\Mailgateway;
use Modules\Mailgateway\Models\Mailgateway; use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Types\LocalType; use Modules\Mailgateway\Types\LocalType;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire; use Livewire\Livewire;
use Modules\Mailgateway\Components\SettingView; use Modules\Mailgateway\Components\SettingView;

View File

@ -7,6 +7,8 @@ use Illuminate\Routing\Router;
use Illuminate\Support\Facades\View; use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Modules\Mailgateway\Components\SettingView; use Modules\Mailgateway\Components\SettingView;
use Modules\Mailgateway\Types\LocalType;
use Modules\Mailgateway\Types\MailmanType;
class MailgatewayServiceProvider extends ServiceProvider class MailgatewayServiceProvider extends ServiceProvider
{ {
@ -32,6 +34,11 @@ class MailgatewayServiceProvider extends ServiceProvider
$router->get('/setting/mailgateway', SettingView::class)->name('setting.mailgateway'); $router->get('/setting/mailgateway', SettingView::class)->name('setting.mailgateway');
}); });
app()->bind('mail-gateways', fn () => collect([
LocalType::class,
MailmanType::class,
]));
View::addNamespace('mailgateway', __DIR__ . '/Components'); View::addNamespace('mailgateway', __DIR__ . '/Components');
} }
} }

View File

@ -2,7 +2,7 @@
namespace Modules\Mailgateway\Models; namespace Modules\Mailgateway\Models;
use App\Mailgateway\Types\Type; use Modules\Mailgateway\Types\Type;
use Illuminate\Database\Eloquent\Concerns\HasUuids; use Illuminate\Database\Eloquent\Concerns\HasUuids;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;

View File

@ -2,8 +2,8 @@
namespace Modules\Mailgateway\Models; namespace Modules\Mailgateway\Models;
use App\Mailgateway\Types\LocalType; use Modules\Mailgateway\Types\Type;
use App\Mailgateway\Types\Type; use Modules\Mailgateway\Types\LocalType;
use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\Factory;
/** /**

View File

@ -2,11 +2,11 @@
namespace Modules\Mailgateway; namespace Modules\Mailgateway;
use App\Mailgateway\Types\LocalType;
use App\Mailgateway\Types\MailmanType;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire; use Livewire\Livewire;
use Modules\Mailgateway\Components\Form; use Modules\Mailgateway\Components\Form;
use Modules\Mailgateway\Types\LocalType;
use Modules\Mailgateway\Types\MailmanType;
use Tests\RequestFactories\MailmanTypeRequest; use Tests\RequestFactories\MailmanTypeRequest;
use Tests\TestCase; use Tests\TestCase;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Mailgateway\Types; namespace Modules\Mailgateway\Types;
use App\Maildispatcher\Data\MailEntry; use App\Maildispatcher\Data\MailEntry;
use App\Maildispatcher\Models\Localmaildispatcher; use App\Maildispatcher\Models\Localmaildispatcher;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Mailgateway\Types; namespace Modules\Mailgateway\Types;
use App\Maildispatcher\Data\MailEntry; use App\Maildispatcher\Data\MailEntry;
use App\Mailman\Data\MailingList; use App\Mailman\Data\MailingList;

View File

@ -1,6 +1,6 @@
<?php <?php
namespace App\Mailgateway\Types; namespace Modules\Mailgateway\Types;
use App\Maildispatcher\Data\MailEntry; use App\Maildispatcher\Data\MailEntry;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@ -3,8 +3,8 @@
namespace Modules\Mailgateway; namespace Modules\Mailgateway;
use Modules\Mailgateway\Models\Mailgateway; use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Types\LocalType; use Modules\Mailgateway\Types\LocalType;
use App\Mailgateway\Types\MailmanType; use Modules\Mailgateway\Types\MailmanType;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire; use Livewire\Livewire;
use Modules\Mailgateway\Components\Form; use Modules\Mailgateway\Components\Form;

View File

@ -7,7 +7,7 @@ use App\Activity;
use App\Maildispatcher\Models\Localmaildispatcher; use App\Maildispatcher\Models\Localmaildispatcher;
use App\Maildispatcher\Models\Maildispatcher; use App\Maildispatcher\Models\Maildispatcher;
use Modules\Mailgateway\Models\Mailgateway; use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Types\LocalType; use Modules\Mailgateway\Types\LocalType;
use App\Member\Member; use App\Member\Member;
use App\Member\Membership; use App\Member\Membership;
use Tests\EndToEndTestCase; use Tests\EndToEndTestCase;

View File

@ -5,10 +5,9 @@ namespace Tests\EndToEnd\Maildispatcher;
use App\Maildispatcher\Actions\ResyncAction; use App\Maildispatcher\Actions\ResyncAction;
use App\Maildispatcher\Models\Maildispatcher; use App\Maildispatcher\Models\Maildispatcher;
use Modules\Mailgateway\Models\Mailgateway; use Modules\Mailgateway\Models\Mailgateway;
use App\Mailgateway\Types\LocalType; use Modules\Mailgateway\Types\LocalType;
use App\Member\FilterScope; use App\Member\FilterScope;
use App\Member\Member; use App\Member\Member;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\EndToEndTestCase; use Tests\EndToEndTestCase;
class UpdateTest extends EndToEndTestCase class UpdateTest extends EndToEndTestCase

View File

@ -2,9 +2,9 @@
namespace Tests\RequestFactories; namespace Tests\RequestFactories;
use App\Mailgateway\Types\MailmanType;
use Illuminate\Support\Facades\Http; use Illuminate\Support\Facades\Http;
use Worksome\RequestFactories\RequestFactory; use Worksome\RequestFactories\RequestFactory;
use Modules\Mailgateway\Types\MailmanType;
class MailmanTypeRequest extends RequestFactory class MailmanTypeRequest extends RequestFactory
{ {