static function logView(Doctrine_Record $record) { $user = sfContext::getInstance()->getUser(); if (!sfConfig::get('app_logging_views') || !$user->isAuthenticated()) { return; } if (!$record->exists()) { throw new Exception("Can't log user view for new record"); } $view = new UserView(); $view->setObject($record); $view->User = $user->getGuardUser(); $view->save(); }