/** * Splits the tags into an array and places them in the relevant tables * @param $text string The text you want to split * @param $row Zend_Db_Table_Row The row you want to associate the tag with * @todo Nail down how I ensure we are passing a Zend_Db_Table_Row object */ public function splitTags($text, $row) { if (empty($text)) { return; } $tags = explode($this->DELIMETER, $text); foreach ($tags as $tag) { // If the tag is "" then skip to the next one if (empty($tag)) { continue; } try { $this->insert(array('name' => $tag)); } catch (Exception $e) { // Do nothing? $this->log->info('Inserting Tag failed, tag was ' . $tag); } $select = $this->select()->where('name = ?', strtolower($tag)); $tag = $this->fetchRow($select); $params = array('tag_id' => $tag->id, 'taggable_id' => $row->id, 'taggable_type' => $row->getTableClass()); $tg = new Tagging(); $this->log->info('Tag id ' . $tag->id); try { $this->log->info(var_export($params, true)); $rowid = $tg->insert($params); $this->log->info('Id: ' . $rowid); } catch (Exception $e) { // Taggable insert fails, dont really worry $this->log->info('Inserting Taggable failed, params were ' . var_export($params, true)); } } }