mirror of
https://github.com/standardebooks/web.git
synced 2025-07-18 12:26:39 -04:00
Some type check fixes
This commit is contained in:
parent
1979b27432
commit
79fdc8c20f
4 changed files with 21 additions and 13 deletions
|
@ -7,6 +7,10 @@ $ebook = null;
|
|||
|
||||
try{
|
||||
$ebook = Ebook::GetByIdentifier($identifier);
|
||||
|
||||
if($ebook->EbookPlaceholder === null){
|
||||
throw new Exceptions\EbookNotFoundException();
|
||||
}
|
||||
}
|
||||
catch(Exceptions\EbookNotFoundException){
|
||||
Template::Emit404();
|
||||
|
|
|
@ -19,19 +19,23 @@ try{
|
|||
if($isCreated){
|
||||
// We got here because an `Ebook` was successfully created.
|
||||
http_response_code(Enums\HttpCode::Created->value);
|
||||
$createdEbook = clone $ebook;
|
||||
if($ebook !== null){
|
||||
$createdEbook = clone $ebook;
|
||||
|
||||
if(sizeof($ebook->CollectionMemberships) > 0){
|
||||
// If the `EbookPlaceholder` we just added is part of a collection, prefill the form with the same data to make it easier to submit series.
|
||||
unset($ebook->EbookId);
|
||||
unset($ebook->Title);
|
||||
$ebook->EbookPlaceholder->YearPublished = null;
|
||||
foreach($ebook->CollectionMemberships as $collectionMembership){
|
||||
$collectionMembership->SequenceNumber++;
|
||||
if(sizeof($ebook->CollectionMemberships) > 0){
|
||||
// If the `EbookPlaceholder` we just added is part of a collection, prefill the form with the same data to make it easier to submit series.
|
||||
unset($ebook->EbookId);
|
||||
unset($ebook->Title);
|
||||
if($ebook->EbookPlaceholder !== null){
|
||||
$ebook->EbookPlaceholder->YearPublished = null;
|
||||
}
|
||||
foreach($ebook->CollectionMemberships as $collectionMembership){
|
||||
$collectionMembership->SequenceNumber++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ebook = null;
|
||||
}
|
||||
}
|
||||
else{
|
||||
$ebook = null;
|
||||
}
|
||||
|
||||
session_unset();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue