Move types

This commit is contained in:
philipp lang 2024-10-24 23:24:21 +02:00
parent 5f511534c3
commit 95e1a98b8e
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\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;

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;
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');

View File

@ -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;

View File

@ -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;

View File

@ -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');
}
}

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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