public function setGitTags($tags, $stable = null) { // delete all current tags which are obsolete $currentTags = array(); foreach ($this->getPluginTags() as $gitTag) { $currentTags[] = $gitTag->getName(); } $deleteTags = array_diff($currentTags, $tags); foreach ($deleteTags as $tag) { $criteria = new Criteria(); $criteria->add(PluginTagPeer::PLUGIN_ID, $this->getId()); $criteria->add(PluginTagPeer::NAME, $tag); PluginTagPeer::doDelete($criteria); } foreach ($tags as $i => $tag) { if (!trim($tag)) { continue; } $existent = $this->getGitTagByName($tag); // if it was marked as stable and it's not the currently stable one, unmark it if ($existent && $existent->isCurrent() && $stable && $existent->getName(true) !== $stable) { $existent->setCurrent(false); $existent->save(); } if (!$existent) { $t = new PluginTag(); $t->setPluginId($this->getId()); $t->setName($tag); if ($stable === null && $i + 1 == sizeof($tags) || floatval($tag) == $stable) { $t->setCurrent(true); } $t->save(); if ($t->isCurrent()) { $this->stable_tag = $t; } } } }