refactor method usage for consistency

This commit is contained in:
Dan Harrin
2025-02-22 10:34:23 +00:00
parent 94faf7d6b6
commit a59edc0d76
16 changed files with 21 additions and 18 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ class AssociateAction extends Action
$this->color('gray');
$this->form(fn (): array => [$this->getRecordSelect()]);
$this->schema(fn (): array => [$this->getRecordSelect()]);
$this->action(function (array $arguments, array $data, Schema $schema, Table $table): void {
/** @var HasMany | MorphMany $relationship */
+1 -1
View File
@@ -68,7 +68,7 @@ class AttachAction extends Action
$this->color('gray');
$this->form(fn (): array => [$this->getRecordSelect()]);
$this->schema(fn (): array => [$this->getRecordSelect()]);
$this->action(function (array $arguments, array $data, Schema $schema, Table $table): void {
/** @var BelongsToMany $relationship */
+1 -1
View File
@@ -86,7 +86,7 @@ trait HasSchema
}
if (is_array($modifiedSchema)) {
$modifiedSchema = $schema->schema($modifiedSchema);
$modifiedSchema = $schema->components($modifiedSchema);
}
if ($this->isSchemaDisabled()) {
+1 -1
View File
@@ -85,7 +85,7 @@ class ImportAction extends Action
$this->groupedIcon(FilamentIcon::resolve('actions::import-action.grouped') ?? Heroicon::ArrowUpTray);
$this->form(fn (ImportAction $action): array => array_merge([
$this->schema(fn (ImportAction $action): array => array_merge([
FileUpload::make('file')
->label(__('filament-actions::import.modal.form.file.label'))
->placeholder(__('filament-actions::import.modal.form.file.placeholder'))
+3 -3
View File
@@ -187,7 +187,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
'label' => $component->getLabel(),
]))
->modalSubmitActionLabel(__('filament-forms::components.builder.actions.add.modal.actions.add.label'))
->form(function (array $arguments, Builder $component): array {
->schema(function (array $arguments, Builder $component): array {
return $component->getBlock($arguments['block'])->getDefaultChildComponents();
});
}
@@ -282,7 +282,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
'label' => $component->getLabel(),
]))
->modalSubmitActionLabel(__('filament-forms::components.builder.actions.add_between.modal.actions.add.label'))
->form(function (array $arguments, Builder $component): array {
->schema(function (array $arguments, Builder $component): array {
return $component->getBlock($arguments['block'])->getDefaultChildComponents();
});
}
@@ -664,7 +664,7 @@ class Builder extends Field implements CanConcealComponents, HasExtraItemActions
return $state[$arguments['item']]['data'];
})
->form(function (array $arguments, Builder $component) {
->schema(function (array $arguments, Builder $component) {
return $component->getChildComponentContainer($arguments['item'])
->getComponents();
})
@@ -23,7 +23,7 @@ class AttachFilesAction
->fillForm(fn (array $arguments): array => [
'alt' => $arguments['alt'] ?? null,
])
->form(fn (array $arguments): array => [
->schema(fn (array $arguments): array => [
FileUpload::make('file')
->label(filled($arguments['src'] ?? null) ? 'Replace file' : 'File')
->acceptedFileTypes(['image/png', 'image/jpeg', 'image/gif', 'image/webp'])
@@ -22,7 +22,7 @@ class LinkAction
'url' => $arguments['url'] ?? null,
'shouldOpenInNewTab' => $arguments['shouldOpenInNewTab'] ?? false,
])
->form([
->schema([
TextInput::make('url')
->label('URL')
->url(),
+2 -2
View File
@@ -281,7 +281,7 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
$action = Action::make($this->getCreateOptionActionName())
->label(__('filament-forms::components.select.actions.create_option.label'))
->form(function (Select $component, Schema $schema): array | Schema | null {
->schema(function (Select $component, Schema $schema): array | Schema | null {
return $component->getCreateOptionActionForm($schema->model(
$component->getRelationship() ? $component->getRelationship()->getModel()::class : null,
));
@@ -436,7 +436,7 @@ class Select extends Field implements Contracts\CanDisableOptions, Contracts\Has
$action = Action::make($this->getEditOptionActionName())
->label(__('filament-forms::components.select.actions.edit_option.label'))
->form(function (Select $component, Schema $schema): array | Schema | null {
->schema(function (Select $component, Schema $schema): array | Schema | null {
return $component->getEditOptionActionForm(
$schema->model($component->getSelectedRecord()),
);
@@ -142,7 +142,7 @@ trait InteractsWithForms /** @phpstan-ignore trait.unused */
public function form(Schema $schema): Schema
{
return $schema
->schema($this->getFormSchema())
->components($this->getFormSchema())
->model($this->getFormModel())
->statePath($this->getFormStatePath())
->operation($this->getFormContext());
@@ -32,7 +32,7 @@ class DisableEmailCodeAuthenticationAction
->modalIcon(Heroicon::OutlinedLockOpen)
->modalHeading(__('filament-panels::auth/multi-factor/email-code/actions/disable.modal.heading'))
->modalDescription(__('filament-panels::auth/multi-factor/email-code/actions/disable.modal.description'))
->form([
->schema([
OneTimeCodeInput::make('code')
->label(__('filament-panels::auth/multi-factor/email-code/actions/disable.modal.form.code.label'))
->validationAttribute(__('filament-panels::auth/multi-factor/email-code/actions/disable.modal.form.code.validation_attribute'))
@@ -42,7 +42,7 @@ class SetUpEmailCodeAuthenticationAction
->modalIconColor('primary')
->modalHeading(__('filament-panels::auth/multi-factor/email-code/actions/set-up.modal.heading'))
->modalDescription(__('filament-panels::auth/multi-factor/email-code/actions/set-up.modal.description'))
->form(fn (array $arguments): array => [
->schema(fn (array $arguments): array => [
OneTimeCodeInput::make('code')
->label(__('filament-panels::auth/multi-factor/email-code/actions/set-up.modal.form.code.label'))
->belowContent(Action::make('resend')
@@ -32,7 +32,7 @@ class DisableGoogleTwoFactorAuthenticationAction
->modalIcon(Heroicon::OutlinedLockOpen)
->modalHeading(__('filament-panels::auth/multi-factor/google-two-factor/actions/disable.modal.heading'))
->modalDescription(__('filament-panels::auth/multi-factor/google-two-factor/actions/disable.modal.description'))
->form([
->schema([
OneTimeCodeInput::make('code')
->label(__('filament-panels::auth/multi-factor/google-two-factor/actions/disable.modal.form.code.label'))
->belowContent(fn (Get $get): Action => Action::make('useRecoveryCode')
@@ -36,7 +36,7 @@ class RegenerateGoogleTwoFactorAuthenticationRecoveryCodesAction
->modalIconColor('primary')
->modalHeading(__('filament-panels::auth/multi-factor/google-two-factor/actions/regenerate-recovery-codes.modal.heading'))
->modalDescription(__('filament-panels::auth/multi-factor/google-two-factor/actions/regenerate-recovery-codes.modal.description'))
->form([
->schema([
OneTimeCodeInput::make('code')
->label(__('filament-panels::auth/multi-factor/google-two-factor/actions/regenerate-recovery-codes.modal.form.code.label'))
->validationAttribute(__('filament-panels::auth/multi-factor/google-two-factor/actions/regenerate-recovery-codes.modal.form.code.validation_attribute'))
+1 -1
View File
@@ -170,7 +170,7 @@ class Login extends SimplePage
public function defaultMultiFactorChallengeForm(Schema $schema): Schema
{
return $schema
->schema(function (): array {
->components(function (): array {
if (blank($this->userUndertakingMultiFactorAuthentication)) {
return [];
}
@@ -182,7 +182,7 @@ class EditRecord extends Page
$this->callHook('beforeValidate');
$data = Schema::make($component->getLivewire())
->schema([$component])
->components([$component])
->model($component->getRecord())
->statePath('data')
->getState();
+3
View File
@@ -1,5 +1,6 @@
<?php
use Filament\Actions\Action;
use Filament\Schemas\Schema;
use Filament\Upgrade\Rector;
use Rector\Config\RectorConfig;
@@ -265,6 +266,8 @@ return static function (RectorConfig $rectorConfig): void {
]);
$rectorConfig->ruleWithConfiguration(RenameMethodRector::class, [
new MethodCallRename(Action::class, 'infolist', 'schema'),
new MethodCallRename(Action::class, 'form', 'schema'),
new MethodCallRename(Schema::class, 'schema', 'components'),
]);
};