示例#1
0
 /**
  * Short method to retrieve sfTaggingCache for internal use
  *
  * @throws sfCacheDisabledException when some mandatory objects are missing
  * @return sfTaggingCache
  */
 protected function getTaggingCache()
 {
     return sfCacheTaggingToolkit::getTaggingCache();
 }
 /**
  * @see Doctrine_Record::unlink()
  * @return sfCachetaggableDoctrineRecord
  */
 public function unlink($alias, $ids = array(), $now = false)
 {
     $self = parent::unlink($alias, $ids, $now);
     try {
         $taggingCache = sfCacheTaggingToolkit::getTaggingCache();
     } catch (sfException $e) {
         return $self;
     }
     $tagNames = $this->getTagNamesByAlias($alias, $ids);
     if (is_array($tagNames)) {
         $taggingCache->deleteTags($tagNames);
     }
     return $self;
 }
 public function getTargetSelectorChoices2($first, $second)
 {
     $tagging_cache = sfCacheTaggingToolkit::getTaggingCache();
     $cache_key = 'Petition_TS2_' . $this->getId() . '_' . (is_scalar($first) && is_scalar($second) ? $first . '__' . $second : md5(json_encode(array($first, $second))));
     $cached_ret = $tagging_cache->get($cache_key, null);
     if ($cached_ret !== null) {
         return $cached_ret;
     }
     $contacts = ContactTable::getInstance()->queryByTargetSelector($this, $first, $second)->execute();
     $pledge_table = PledgeTable::getInstance();
     $choices = array();
     $active_pledge_item_ids = $this->getActivePledgeItemIds();
     $pledge_info_columns = $this->getPledgeInfoColumnsArray();
     $pledges = $pledge_table->getPledgesForContacts($contacts, $active_pledge_item_ids);
     $infos = ContactTable::getInstance()->getPledgeInfoColumns($contacts, $pledge_info_columns);
     foreach ($contacts as $contact) {
         /* @var $contact Contact */
         $choices[$contact['id']] = $contact['firstname'] . ' ' . $contact['lastname'];
     }
     $ret = array('choices' => $choices, 'pledges' => $pledges, 'infos' => $infos);
     $tags = $this->getCacheTags();
     if ($this->getMailingListId()) {
         $tags = array_merge($tags, $this->getMailingList()->getCacheTags());
     }
     $tagging_cache->set($cache_key, $ret, 24 * 3600, $tags);
     return $ret;
 }