#!/usr/bin/php getMessage() . "\n"); exit(1); } if($verbose){ print("Title: $ebook->Title\n"); print("Identifier: $ebook->Identifier\n"); } try{ $ebook->CreateOrUpdate(); // If there was an `EbookPlaceholder` for this ebook, delete it. $ebook->EbookPlaceholder?->Delete(); // If there was a `Project` for this ebook, mark it as completed. if($ebook->ProjectInProgress !== null){ $ebook->ProjectInProgress->Status = Enums\ProjectStatusType::Completed; $ebook->ProjectInProgress->Ended = NOW; $ebook->ProjectInProgress->Save(); } } catch(Exceptions\ValidationException $validationException){ $exceptions = $validationException->Exceptions; if(count($exceptions) == 1){ print("\nA ValidationException occurred when updating the ebook database:\n"); print("\t" . get_class($exceptions[0]) . ": " . $exceptions[0]->getMessage() . "\n"); print("[ERROR] Found 1 error\n"); } else{ print("\nValidationExceptions when updating the ebook database:\n"); foreach($exceptions as $ex){ print("\t" . get_class($ex) . ": " . $ex->getMessage() . "\n"); } print("[ERROR] Found " . count($exceptions) . " errors\n"); } exit(1); } exit(0);