Rename Insert*Strings() to Create*()

Also rename:

Insert*() to Add*()
Delete*() to Remove*()
This commit is contained in:
Mike Colagrosso 2024-10-11 11:50:05 -06:00 committed by Alex Cabal
parent 16c7c2ffd8
commit 38860c4729

View file

@ -1268,7 +1268,7 @@ class Ebook{
/** /**
* @throws Exceptions\ValidationException * @throws Exceptions\ValidationException
*/ */
private function InsertTagStrings(): void{ private function CreateTags(): void{
$tags = []; $tags = [];
foreach($this->Tags as $ebookTag){ foreach($this->Tags as $ebookTag){
$tags[] = $ebookTag->GetByNameOrCreate($ebookTag->Name); $tags[] = $ebookTag->GetByNameOrCreate($ebookTag->Name);
@ -1279,7 +1279,7 @@ class Ebook{
/** /**
* @throws Exceptions\ValidationException * @throws Exceptions\ValidationException
*/ */
private function InsertLocSubjectStrings(): void{ private function CreateLocSubjects(): void{
$subjects = []; $subjects = [];
foreach($this->LocSubjects as $locSubject){ foreach($this->LocSubjects as $locSubject){
$subjects[] = $locSubject->GetByNameOrCreate($locSubject->Name); $subjects[] = $locSubject->GetByNameOrCreate($locSubject->Name);
@ -1290,7 +1290,7 @@ class Ebook{
/** /**
* @throws Exceptions\ValidationException * @throws Exceptions\ValidationException
*/ */
private function InsertCollections(): void{ private function CreateCollections(): void{
$collectionMemberships = []; $collectionMemberships = [];
foreach($this->CollectionMemberships as $collectionMembership){ foreach($this->CollectionMemberships as $collectionMembership){
$collection = $collectionMembership->Collection; $collection = $collectionMembership->Collection;
@ -1566,9 +1566,9 @@ class Ebook{
public function Create(): void{ public function Create(): void{
$this->Validate(); $this->Validate();
$this->InsertTagStrings(); $this->CreateTags();
$this->InsertLocSubjectStrings(); $this->CreateLocSubjects();
$this->InsertCollections(); $this->CreateCollections();
Db::Query(' Db::Query('
INSERT into Ebooks (Identifier, WwwFilesystemPath, RepoFilesystemPath, KindleCoverUrl, EpubUrl, INSERT into Ebooks (Identifier, WwwFilesystemPath, RepoFilesystemPath, KindleCoverUrl, EpubUrl,
@ -1606,13 +1606,13 @@ class Ebook{
$this->EbookId = Db::GetLastInsertedId(); $this->EbookId = Db::GetLastInsertedId();
$this->InsertTags(); $this->AddTags();
$this->InsertLocSubjects(); $this->AddLocSubjects();
$this->InsertCollectionMemberships(); $this->AddCollectionMemberships();
$this->InsertGitCommits(); $this->AddGitCommits();
$this->InsertSources(); $this->AddSources();
$this->InsertContributors(); $this->AddContributors();
$this->InsertTocEntries(); $this->AddTocEntries();
} }
/** /**
@ -1621,9 +1621,9 @@ class Ebook{
public function Save(): void{ public function Save(): void{
$this->Validate(); $this->Validate();
$this->InsertTagStrings(); $this->CreateTags();
$this->InsertLocSubjectStrings(); $this->CreateLocSubjects();
$this->InsertCollections(); $this->CreateCollections();
Db::Query(' Db::Query('
UPDATE Ebooks UPDATE Ebooks
@ -1660,29 +1660,29 @@ class Ebook{
$this->EbookCreated, $this->EbookUpdated, $this->TextSinglePageByteCount, $this->IndexableText, $this->EbookCreated, $this->EbookUpdated, $this->TextSinglePageByteCount, $this->IndexableText,
$this->EbookId]); $this->EbookId]);
$this->DeleteTags(); $this->RemoveTags();
$this->InsertTags(); $this->AddTags();
$this->DeleteLocSubjects(); $this->RemoveLocSubjects();
$this->InsertLocSubjects(); $this->AddLocSubjects();
$this->DeleteCollectionMemberships(); $this->RemoveCollectionMemberships();
$this->InsertCollectionMemberships(); $this->AddCollectionMemberships();
$this->DeleteGitCommits(); $this->RemoveGitCommits();
$this->InsertGitCommits(); $this->AddGitCommits();
$this->DeleteSources(); $this->RemoveSources();
$this->InsertSources(); $this->AddSources();
$this->DeleteContributors(); $this->RemoveContributors();
$this->InsertContributors(); $this->AddContributors();
$this->DeleteTocEntries(); $this->RemoveTocEntries();
$this->InsertTocEntries(); $this->AddTocEntries();
} }
private function DeleteTags(): void{ private function RemoveTags(): void{
Db::Query(' Db::Query('
DELETE from EbookTags DELETE from EbookTags
where EbookId = ? where EbookId = ?
@ -1690,7 +1690,7 @@ class Ebook{
); );
} }
private function InsertTags(): void{ private function AddTags(): void{
foreach($this->Tags as $tag){ foreach($this->Tags as $tag){
Db::Query(' Db::Query('
INSERT into EbookTags (EbookId, TagId) INSERT into EbookTags (EbookId, TagId)
@ -1700,7 +1700,7 @@ class Ebook{
} }
} }
private function DeleteLocSubjects(): void{ private function RemoveLocSubjects(): void{
Db::Query(' Db::Query('
DELETE from EbookLocSubjects DELETE from EbookLocSubjects
where EbookId = ? where EbookId = ?
@ -1708,7 +1708,7 @@ class Ebook{
); );
} }
private function InsertLocSubjects(): void{ private function AddLocSubjects(): void{
foreach($this->LocSubjects as $locSubject){ foreach($this->LocSubjects as $locSubject){
Db::Query(' Db::Query('
INSERT into EbookLocSubjects (EbookId, LocSubjectId) INSERT into EbookLocSubjects (EbookId, LocSubjectId)
@ -1718,7 +1718,7 @@ class Ebook{
} }
} }
private function DeleteCollectionMemberships(): void{ private function RemoveCollectionMemberships(): void{
Db::Query(' Db::Query('
DELETE from CollectionEbooks DELETE from CollectionEbooks
where EbookId = ? where EbookId = ?
@ -1726,7 +1726,7 @@ class Ebook{
); );
} }
private function InsertCollectionMemberships(): void{ private function AddCollectionMemberships(): void{
foreach($this->CollectionMemberships as $collectionMembership){ foreach($this->CollectionMemberships as $collectionMembership){
$collectionMembership->EbookId = $this->EbookId; $collectionMembership->EbookId = $this->EbookId;
$collectionMembership->CollectionId = $collectionMembership->Collection->CollectionId; $collectionMembership->CollectionId = $collectionMembership->Collection->CollectionId;
@ -1742,7 +1742,7 @@ class Ebook{
} }
} }
private function DeleteGitCommits(): void{ private function RemoveGitCommits(): void{
Db::Query(' Db::Query('
DELETE from GitCommits DELETE from GitCommits
where EbookId = ? where EbookId = ?
@ -1753,14 +1753,14 @@ class Ebook{
/** /**
* @throws Exceptions\ValidationException * @throws Exceptions\ValidationException
*/ */
private function InsertGitCommits(): void{ private function AddGitCommits(): void{
foreach($this->GitCommits as $commit){ foreach($this->GitCommits as $commit){
$commit->EbookId = $this->EbookId; $commit->EbookId = $this->EbookId;
$commit->Create(); $commit->Create();
} }
} }
private function DeleteSources(): void{ private function RemoveSources(): void{
Db::Query(' Db::Query('
DELETE from EbookSources DELETE from EbookSources
where EbookId = ? where EbookId = ?
@ -1771,14 +1771,14 @@ class Ebook{
/** /**
* @throws Exceptions\ValidationException * @throws Exceptions\ValidationException
*/ */
private function InsertSources(): void{ private function AddSources(): void{
foreach($this->Sources as $source){ foreach($this->Sources as $source){
$source->EbookId = $this->EbookId; $source->EbookId = $this->EbookId;
$source->Create(); $source->Create();
} }
} }
private function DeleteContributors(): void{ private function RemoveContributors(): void{
Db::Query(' Db::Query('
DELETE from Contributors DELETE from Contributors
where EbookId = ? where EbookId = ?
@ -1789,7 +1789,7 @@ class Ebook{
/** /**
* @throws Exceptions\ValidationException * @throws Exceptions\ValidationException
*/ */
private function InsertContributors(): void{ private function AddContributors(): void{
$allContributors = array_merge($this->Authors, $this->Illustrators, $this->Translators, $this->Contributors); $allContributors = array_merge($this->Authors, $this->Illustrators, $this->Translators, $this->Contributors);
foreach($allContributors as $sortOrder => $contributor){ foreach($allContributors as $sortOrder => $contributor){
$contributor->EbookId = $this->EbookId; $contributor->EbookId = $this->EbookId;
@ -1798,7 +1798,7 @@ class Ebook{
} }
} }
private function DeleteTocEntries(): void{ private function RemoveTocEntries(): void{
Db::Query(' Db::Query('
DELETE from TocEntries DELETE from TocEntries
where EbookId = ? where EbookId = ?
@ -1806,7 +1806,7 @@ class Ebook{
); );
} }
private function InsertTocEntries(): void{ private function AddTocEntries(): void{
if($this->TocEntries !== null){ if($this->TocEntries !== null){
foreach($this->TocEntries as $tocEntry){ foreach($this->TocEntries as $tocEntry){
Db::Query(' Db::Query('