public function savePcContactsTagsList($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (!isset($this->widgetSchema['pc_contacts_tags_list'])) { // somebody has unset this widget return; } if (null === $con) { $con = $this->getConnection(); } $c = new Criteria(); $c->add(PcContactsTagsPeer::TAG_ID, $this->object->getPrimaryKey()); PcContactsTagsPeer::doDelete($c, $con); $values = $this->getValue('pc_contacts_tags_list'); if (is_array($values)) { foreach ($values as $value) { $obj = new PcContactsTags(); $obj->setTagId($this->object->getPrimaryKey()); $obj->setContactId($value); $obj->save(); } } }
/** * * @param array|null $tagIds */ public function updateTags($tagIds) { // first remove all the pre-existing tags $c = new Criteria(); $c->add(PcContactsTagsPeer::CONTACT_ID, $this->getId()); PcContactsTagsPeer::doDelete($c); if (is_array($tagIds)) { foreach ($tagIds as $tagId) { $entry = new PcContactsTags(); $entry->setContactId($this->getId())->setPcUser(PcUserPeer::getLoggedInUser())->setTagId($tagId)->save(); } } return $this; }