Make MARC roles an enum and restructure how contributors are fetched from the DB to reduce queries

This commit is contained in:
Alex Cabal 2024-11-11 12:01:53 -06:00
parent daf8e16ef4
commit d6a2bdcbc8
8 changed files with 91 additions and 75 deletions

View file

@ -7,7 +7,7 @@ class Contributor{
public string $UrlName;
public ?string $SortName = null;
public ?string $WikipediaUrl = null;
public ?string $MarcRole = null;
public Enums\MarcRole $MarcRole;
public ?string $FullName = null;
public ?string $NacoafUrl = null;
public int $SortOrder;
@ -32,19 +32,14 @@ class Contributor{
if($this->Name == ''){
$error->Add(new Exceptions\ContributorNameRequiredException());
}
$this->UrlName = Formatter::MakeUrlSafe($this->Name);
}
else{
$error->Add(new Exceptions\ContributorNameRequiredException());
}
if(isset($this->UrlName)){
$this->UrlName = trim($this->UrlName);
if($this->UrlName == ''){
$error->Add(new Exceptions\ContributorUrlNameRequiredException());
}
}
else{
if(!isset($this->UrlName)){
$error->Add(new Exceptions\ContributorUrlNameRequiredException());
}
@ -73,11 +68,6 @@ class Contributor{
}
}
$this->MarcRole = trim($this->MarcRole ?? '');
if($this->MarcRole == ''){
$this->MarcRole = null;
}
$this->NacoafUrl = trim($this->NacoafUrl ?? '');
if($this->NacoafUrl == ''){
$this->NacoafUrl = null;