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();
         }
     }
 }
Esempio n. 2
0
 /**
  *
  * @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;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      PcContactsTags $value A PcContactsTags object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(PcContactsTags $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = serialize(array((string) $obj->getContactId(), (string) $obj->getTagId()));
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }