Captures the current working tree after theme slots, ArticleAccess, and the payment / paid-content plugins so subsequent work has a reviewable git history.
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\Articles\Pages;
|
|
|
|
use App\Domain\Ai\Jobs\OptimizeArticleContentJob;
|
|
use App\Domain\Plugin\Hook;
|
|
use App\Filament\Resources\Articles\ArticleResource;
|
|
use Filament\Actions\Action;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
|
|
class EditArticle extends EditRecord
|
|
{
|
|
protected static string $resource = ArticleResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('aiOptimize')
|
|
->label(__('admin.messages.ai_optimize'))
|
|
->action(function (): void {
|
|
OptimizeArticleContentJob::dispatch($this->record->getKey());
|
|
Notification::make()
|
|
->title(__('admin.messages.ai_optimize_queued'))
|
|
->body(__('admin.messages.ai_optimize_queue_hint'))
|
|
->success()
|
|
->send();
|
|
}),
|
|
DeleteAction::make(),
|
|
...Hook::collect('filament.article.actions'),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
* @return array<string, mixed>
|
|
*/
|
|
protected function mutateFormDataBeforeFill(array $data): array
|
|
{
|
|
$filtered = Hook::filter('filament.article.mutate_before_fill', $data, $this->record);
|
|
|
|
return is_array($filtered) ? $filtered : $data;
|
|
}
|
|
|
|
/**
|
|
* @param array<string, mixed> $data
|
|
* @return array<string, mixed>
|
|
*/
|
|
protected function mutateFormDataBeforeSave(array $data): array
|
|
{
|
|
$filtered = Hook::filter('filament.article.mutate_before_save', $data, $this->record);
|
|
|
|
return is_array($filtered) ? $filtered : $data;
|
|
}
|
|
|
|
protected function afterSave(): void
|
|
{
|
|
Hook::dispatch('filament.article.after_save', $this->record, $this->form->getState());
|
|
}
|
|
}
|