/**
  * @param Doctrine_Table|string $table
  * @param string $keyColumn
  * @see Doctrine_Collection::__construct()
  */
 public function __construct($table, $keyColumn = null)
 {
     parent::__construct($table, $keyColumn);
     $this->namespace = sprintf('%s/%s/%s', sfCacheTaggingToolkit::getBaseClassName(get_class($this)), $this->getTable()->getClassnameToReturn(), sfCacheTaggingToolkit::generateVersion());
 }
 /**
  * Builds tag name by keyFormat and passed values
  *
  * @param string  $keyFormat
  * @param array   $values
  * @return string
  */
 public static function buildTagKey(Doctrine_Template_Cachetaggable $template, $keyFormat, array $values)
 {
     /**
      * First element is object's class name
      */
     $columnValues = array(sfCacheTaggingToolkit::getBaseClassName($template->getTable()->getClassnameToReturn()));
     /**
      * following elements are row's "candidate keys"
      * @link http://databases.about.com/cs/specificproducts/g/candidate.htm
      */
     $columnValues = array_merge($columnValues, $values);
     return call_user_func_array('sprintf', array_merge(array($keyFormat), $columnValues));
 }
 /**
  * pre dql delete hook - remove object tags from tagger
  *
  * @param Doctrine_Event $event
  * @return null
  */
 public function preDqlDelete(Doctrine_Event $event)
 {
     $taggingCache = null;
     try {
         $taggingCache = $this->getTaggingCache();
     } catch (sfCacheException $e) {
         return;
     }
     $table = $event->getInvoker()->getTable();
     /* @var $q Doctrine_Query */
     $q = clone $event->getQuery();
     /**
      * This happens, when SoftDelete is declared before Cachetaggable
      */
     if (Doctrine_Query::UPDATE === $q->getType()) {
         $event->getQuery()->set($this->getOption('versionColumn'), sfCacheTaggingToolkit::generateVersion());
         $q->removeDqlQueryPart('set');
     }
     $params = $q->getParams();
     $params['set'] = array();
     $q->setParams($params);
     $objects = $q->select()->execute();
     $unitOfWork = new Doctrine_Connection_CachetaggableUnitOfWork($q->getConnection());
     foreach ($objects as $object) {
         $unitOfWork->collectDeletionsAndInvalidations($object);
         $taggingCache->deleteTags($unitOfWork->getDeletions());
         $taggingCache->invalidateTags($unitOfWork->getInvalidations());
     }
     unset($unitOfWork);
     $taggingCache->setTag(sfCacheTaggingToolkit::getBaseClassName($table->getClassnameToReturn()), sfCacheTaggingToolkit::generateVersion());
 }