mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 17:42:29 -04:00
Use setter function when setting artwork tags
This commit is contained in:
parent
8a82524de7
commit
716fc8bea9
2 changed files with 23 additions and 21 deletions
|
@ -56,6 +56,27 @@ class Artwork extends PropertiesBase{
|
|||
protected ?User $_Reviewer = null;
|
||||
protected ?ImageMimeType $_MimeType = null;
|
||||
|
||||
// *******
|
||||
// SETTERS
|
||||
// *******
|
||||
|
||||
protected function SetTags(string|array|null $tags): void{
|
||||
if($tags === null || is_array($tags)){
|
||||
$this->_Tags = $tags;
|
||||
}
|
||||
elseif(is_string($tags)){
|
||||
$tags = array_map('trim', explode(',', $tags));
|
||||
$tags = array_values(array_filter($tags));
|
||||
$tags = array_unique($tags);
|
||||
|
||||
$this->_Tags = array_map(function ($str){
|
||||
$tag = new ArtworkTag();
|
||||
$tag->Name = $str;
|
||||
return $tag;
|
||||
}, $tags);
|
||||
}
|
||||
}
|
||||
|
||||
// *******
|
||||
// GETTERS
|
||||
// *******
|
||||
|
@ -382,21 +403,6 @@ class Artwork extends PropertiesBase{
|
|||
}
|
||||
}
|
||||
|
||||
/** @return array<ArtworkTag> */
|
||||
public static function ParseTags(?string $tags): array{
|
||||
if(!$tags) return [];
|
||||
|
||||
$tags = array_map('trim', explode(',', $tags));
|
||||
$tags = array_values(array_filter($tags));
|
||||
$tags = array_unique($tags);
|
||||
|
||||
return array_map(function ($str){
|
||||
$tag = new ArtworkTag();
|
||||
$tag->Name = $str;
|
||||
return $tag;
|
||||
}, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<mixed> $uploadedFile
|
||||
* @throws \Exceptions\ValidationException
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue