mirror of
https://github.com/standardebooks/web.git
synced 2025-07-13 10:02:02 -04:00
Add PropertyFromHttp trait and update codebase to use new pattern
This commit is contained in:
parent
c35c47b793
commit
acb30b897c
47 changed files with 851 additions and 527 deletions
|
@ -7,18 +7,20 @@ class ArtworkTag extends Tag{
|
|||
$this->Type = Enums\TagType::Artwork;
|
||||
}
|
||||
|
||||
|
||||
// *******
|
||||
// GETTERS
|
||||
// *******
|
||||
|
||||
protected function GetUrl(): string{
|
||||
if($this->_Url === null){
|
||||
if(!isset($this->_Url)){
|
||||
$this->_Url = '/artworks?query=' . Formatter::MakeUrlSafe($this->Name);
|
||||
}
|
||||
|
||||
return $this->_Url;
|
||||
}
|
||||
|
||||
|
||||
// *******
|
||||
// METHODS
|
||||
// *******
|
||||
|
@ -29,20 +31,27 @@ class ArtworkTag extends Tag{
|
|||
public function Validate(): void{
|
||||
$error = new Exceptions\InvalidArtworkTagException($this->Name);
|
||||
|
||||
$this->Name = mb_strtolower(trim($this->Name));
|
||||
// Collapse spaces into one
|
||||
$this->Name = preg_replace('/[\s]+/ius', ' ', $this->Name);
|
||||
if(isset($this->Name)){
|
||||
$this->Name = mb_strtolower(trim($this->Name));
|
||||
// Collapse spaces into one
|
||||
$this->Name = preg_replace('/[\s]+/ius', ' ', $this->Name);
|
||||
|
||||
if(strlen($this->Name) == 0){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
if(strlen($this->Name) == 0){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
}
|
||||
|
||||
if(strlen($this->Name) > ARTWORK_MAX_STRING_LENGTH){
|
||||
$error->Add(new Exceptions\StringTooLongException('Artwork tag: '. $this->Name));
|
||||
}
|
||||
|
||||
if(preg_match('/[^\sa-z0-9]/ius', $this->Name)){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
}
|
||||
|
||||
$this->UrlName = Formatter::MakeUrlSafe($this->Name);
|
||||
}
|
||||
|
||||
if(strlen($this->Name) > ARTWORK_MAX_STRING_LENGTH){
|
||||
$error->Add(new Exceptions\StringTooLongException('Artwork tag: '. $this->Name));
|
||||
}
|
||||
|
||||
if(preg_match('/[^\sa-z0-9]/ius', $this->Name)){
|
||||
$error->Add(new Exceptions\InvalidArtworkTagNameException());
|
||||
else{
|
||||
$error->Add(new Exceptions\ArtworkTagNameRequiredException());
|
||||
}
|
||||
|
||||
if($this->Type != Enums\TagType::Artwork){
|
||||
|
@ -61,10 +70,11 @@ class ArtworkTag extends Tag{
|
|||
$this->Validate();
|
||||
|
||||
Db::Query('
|
||||
INSERT into Tags (Name, Type)
|
||||
INSERT into Tags (Name, UrlName, Type)
|
||||
values (?,
|
||||
?,
|
||||
?)
|
||||
', [$this->Name, $this->Type]);
|
||||
', [$this->Name, $this->UrlName, $this->Type]);
|
||||
$this->TagId = Db::GetLastInsertedId();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue