public function executeCounter()
 {
     $object = $this->object;
     $this->counter = $object->getCounter();
     if ($object instanceof sfOutputEscaperObjectDecorator) {
         $object_class = get_class($object->getRawValue());
     } else {
         $object_class = get_class($object);
     }
     $this->token = sfPropelActAsCountableToolkit::addTokenToSession($object_class, $object->getPrimaryKey());
 }
 /**
  * Saves a comment, for an authentified user
  */
 public function executeIncrementCounter()
 {
     $token = $this->getRequestParameter('sf_countable_token');
     $object = sfPropelActAsCountableToolkit::retrieveFromToken($token);
     if ($object) {
         $context = sfContext::getInstance();
         if (!$context->getRequest()->getCookie($token) == $token) {
             $object->incrementCounter();
             $context->getResponse()->setCookie($token, $token);
         }
         $this->counter = $object->getCounter();
     } else {
         $this->counter = 0;
     }
 }
 /**
  * Retrieve a countable object
  * 
  * @param  string  $object_model
  * @param  int     $object_id
  */
 public static function retrieveCountableObject($object_model, $object_id)
 {
     try {
         $peer = sprintf('%sPeer', $object_model);
         if (!class_exists($peer)) {
             throw new Exception(sprintf('Unable to load class %s', $peer));
         }
         $object = call_user_func(array($peer, 'retrieveByPk'), $object_id);
         if (is_null($object)) {
             throw new Exception(sprintf('Unable to retrieve %s with primary key %s', $object_model, $object_id));
         }
         if (!sfPropelActAsCountableToolkit::isCountable($object)) {
             throw new Exception(sprintf('Class %s does not have the countable behavior', $object_model));
         }
         return $object;
     } catch (Exception $e) {
         return sfContext::getInstance()->getLogger()->log($e->getMessage());
     }
 }