mirror of
https://github.com/standardebooks/web.git
synced 2025-07-08 07:40:39 -04:00
Restructure how incorrect ebook URLs are redirected
This commit is contained in:
parent
d6a2bdcbc8
commit
d4c7703cf0
6 changed files with 62 additions and 72 deletions
|
@ -766,6 +766,7 @@ class Ebook{
|
|||
foreach($xml->xpath('/package/metadata/meta[@property="se:subject"]') ?: [] as $tag){
|
||||
$ebookTag = new EbookTag();
|
||||
$ebookTag->Name = $tag;
|
||||
$ebookTag->UrlName = Formatter::MakeUrlSafe($ebookTag->Name);
|
||||
$tags[] = $ebookTag;
|
||||
}
|
||||
$ebook->Tags = $tags;
|
||||
|
@ -1855,17 +1856,26 @@ class Ebook{
|
|||
throw new Exceptions\EbookNotFoundException('Invalid identifier: ' . $identifier);
|
||||
}
|
||||
|
||||
$result = Db::Query('
|
||||
return Db::Query('
|
||||
SELECT *
|
||||
from Ebooks
|
||||
where Identifier = ?
|
||||
', [$identifier], Ebook::class);
|
||||
', [$identifier], Ebook::class)[0] ?? throw new Exceptions\EbookNotFoundException('Invalid identifier: ' . $identifier);
|
||||
}
|
||||
|
||||
if(sizeof($result) == 0){
|
||||
/**
|
||||
* @throws Exceptions\EbookNotFoundException
|
||||
*/
|
||||
public static function GetByIdentifierStartingWith(?string $identifier): Ebook{
|
||||
if($identifier === null){
|
||||
throw new Exceptions\EbookNotFoundException('Invalid identifier: ' . $identifier);
|
||||
}
|
||||
|
||||
return $result[0];
|
||||
return Db::Query('
|
||||
SELECT *
|
||||
from Ebooks
|
||||
where Identifier like concat(?, "%")
|
||||
', [$identifier], Ebook::class)[0] ?? throw new Exceptions\EbookNotFoundException('Invalid identifier: ' . $identifier);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue