modules/tag/models/Tag.php
public static function addTags($tags, $tagType)
    {
        foreach ($tags as $name) {
            $tag = self::find()
                ->where(['name' => $name])
                ->andWhere(['tag_type' => $tagType])
                ->one();

            //if tag does not exists, insert it
            if (is_null($tag)) {
                $tag = new self();
                $tag->name = $name;
                $tag->tag_type = $tagType;
                $tag->frequency = self::DEFAULT_FREQUENCY;
                $tag->save(false);
            } else {
                //Update count of tags already exists
                $tag->updateCounters(['frequency' => self::DEFAULT_FREQUENCY]);
            }
        }
    }
public static function addTags($tags, $tagType)
    {
        foreach ($tags as $name) {
            $tag = self::find()
                ->where(['name' => $name])
                ->andWhere(['tag_type' => $tagType])
                ->one();

            //if tag does not exists, insert it
            if (is_null($tag)) {
                $tag = new self();
                $tag->name = $name;
                $tag->tag_type = $tagType;
                $tag->frequency = self::DEFAULT_FREQUENCY;
                $tag->save(false);
            } else {
                //Update count of tags already exists
                $tag->updateCounters(['frequency' => self::DEFAULT_FREQUENCY]);
            }
        }
    }
Update count of tags already exists
if tag does not exists, insert it
@param $tags
@param $tagType