Skip to content

Commit

Permalink
Delegate BadMethodCallException throwing to a protected method
Browse files Browse the repository at this point in the history
  • Loading branch information
Voltra committed Jun 24, 2024
1 parent 555c773 commit 068cde5
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/Forms/IconPicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,21 @@ public function getSearchResults(string $search): array
return $results;
}

/**
* Marks the calling method as not allowed (whether because it's not supported or because it's meaningless when using this field)
* @throws \BadMethodCallException Always
*/
protected function markAsNotAllowed(string $reason = 'Method not allowed.'): void {
throw new \BadMethodCallException($reason);
}

/**
* @deprecated Method inherited from `\Filament\Forms\Components\Select` but not supported (or meaningless) when using this field
* @throws \BadMethodCallException
*/
public function relationship(string|Closure|null $name = null, string|Closure|null $titleAttribute = null, ?Closure $modifyQueryUsing = null, bool $ignoreRecord = false): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -178,7 +186,7 @@ public function relationship(string|Closure|null $name = null, string|Closure|nu
*/
public function options(Arrayable|Closure|array|string|null $options): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -187,7 +195,7 @@ public function options(Arrayable|Closure|array|string|null $options): static
*/
public function allowHtml(bool|Closure $condition = true): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -196,7 +204,7 @@ public function allowHtml(bool|Closure $condition = true): static
*/
public function searchable(bool|array|Closure $condition = true): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -205,7 +213,7 @@ public function searchable(bool|array|Closure $condition = true): static
*/
public function getSearchResultsUsing(?Closure $callback): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -214,7 +222,7 @@ public function getSearchResultsUsing(?Closure $callback): static
*/
public function getOptionLabelFromRecordUsing(?Closure $callback): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -223,7 +231,7 @@ public function getOptionLabelFromRecordUsing(?Closure $callback): static
*/
public function createOptionUsing(?Closure $callback): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -232,7 +240,7 @@ public function createOptionUsing(?Closure $callback): static
*/
public function createOptionAction(?Closure $callback): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -241,7 +249,7 @@ public function createOptionAction(?Closure $callback): static
*/
public function createOptionForm(array|Closure|null $schema): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -250,7 +258,7 @@ public function createOptionForm(array|Closure|null $schema): static
*/
public function schema(array|Closure $components): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

/**
Expand All @@ -259,7 +267,7 @@ public function schema(array|Closure $components): static
*/
public function multiple(bool|Closure $condition = true): static
{
throw new \BadMethodCallException('Method not allowed.');
$this->markAsNotAllowed();
}

private function loadIcons(): Collection
Expand Down

0 comments on commit 068cde5

Please sign in to comment.