Code snippets for symfony 1.x


Refine Tags

Snippets tagged "profile"

Using timers to profile functions speed

This snippet allows you to evaluate functions speed and display them in symfony debug bar.

$timer = sfTimerManager::getTimer ('ldap_request'); // Create and start a new timer
// do some stuff
$timer->addTime (); // stop and store the timer value
by Arnaud Didry on 2009-06-22, tagged performance  profile  speed 

Create profile after adding a new user, the simple way.

Sometimes if you use sfGuardUser and sfGuardUserProfile you need to create an empty profile just after adding the new user (automating is such a great thing). This snippet will help out.

UPDATE: Will Killian pointed me to the solution of using this without touching the plugin files, this way it will still work after upgrading the plugin. Thanks!

Edit apps/backend/modules/sfGuardUser/actions/actions.class.php

(create directories and files as needed, just for the record I use this with admin generator on "backend" app)

Mine looks like this.

class sfGuardUserActions extends BasesfGuardUserActions
  protected function savesfGuardUser($sf_guard_user)
    $user_id = $sf_guard_user->getId();
    $c = new Criteria();
    $profile = sfGuardUserProfilePeer::doSelectOne($c);
    if(!$profile) {
      $profile = new sfGuardUserProfile();
by Roberto Carvajal on 2007-10-30, tagged profile  sfguard  user