Skip to content

Commit

Permalink
Throw if the canonical field is not set in type
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Dec 18, 2022
1 parent e98d8e1 commit 5a8a1a9
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ public function getFieldRules(bool $reload = false): Collection

public function getCanonicalFieldDefinition(): PublicationFieldType
{
return $this->getFields()->filter(fn(PublicationFieldType $field): bool => $field->name === $this->canonicalField)->first();
return $this->getFields()->filter(fn(PublicationFieldType $field): bool => $field->name === $this->canonicalField)->first()
?? throw new RuntimeException("Could not find canonical field '$this->canonicalField'");
}

public function save(?string $path = null): void
Expand Down

0 comments on commit 5a8a1a9

Please sign in to comment.