mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Add a Type enum to Tags for artwork/ebook
This commit is contained in:
parent
ee29c526f8
commit
402dae95ff
7 changed files with 62 additions and 10 deletions
|
@ -3,6 +3,10 @@ use function Safe\preg_match;
|
|||
use function Safe\preg_replace;
|
||||
|
||||
class ArtworkTag extends Tag{
|
||||
public function __construct(){
|
||||
$this->Type = 'artwork';
|
||||
}
|
||||
|
||||
// *******
|
||||
// GETTERS
|
||||
// *******
|
||||
|
@ -41,6 +45,10 @@ class ArtworkTag extends Tag{
|
|||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
}
|
||||
|
||||
if($this->Type != 'artwork'){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagTypeException($this->Type));
|
||||
}
|
||||
|
||||
if($error->HasExceptions){
|
||||
throw $error;
|
||||
}
|
||||
|
@ -53,9 +61,10 @@ class ArtworkTag extends Tag{
|
|||
$this->Validate();
|
||||
|
||||
Db::Query('
|
||||
INSERT into Tags (Name)
|
||||
values (?)
|
||||
', [$this->Name]);
|
||||
INSERT into Tags (Name, Type)
|
||||
values (?,
|
||||
?)
|
||||
', [$this->Name, $this->Type]);
|
||||
$this->TagId = Db::GetLastInsertedId();
|
||||
}
|
||||
|
||||
|
@ -67,6 +76,7 @@ class ArtworkTag extends Tag{
|
|||
SELECT *
|
||||
from Tags
|
||||
where Name = ?
|
||||
and Type = "artwork"
|
||||
', [$artworkTag->Name], ArtworkTag::class);
|
||||
|
||||
if(isset($result[0])){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue