public static function CreateOrFind($tagName) { $tagService = new TagService(); $tag = $tagService->getTagByName($tagName); if (!$tag) { $tag = new Models\Tag(); $tag->name = $tagName; $tag->save(); } return $tag; }
public function addTag(Models\Image $image, Models\Tag $tag, Models\User $user = null) { $imageTagLink = new Models\ImageTagLink(); $imageTagLink->file_id = $image->file_id; $imageTagLink->tag_id = $tag->tag_id; if ($user) { $imageTagLink->created_user = $user->user_id; } $imageTagLink->save(); $tag->updatePopularityCount(); return $imageTagLink; }