phpsymfony-1.4propelsfguard

access to extended class in symfony 1.4


so... I basically follow the practical symfony book, and encountered following problem. I have properly (i guess) installed sfGuardPlugin, built the models, sqls etc, created user and tried to log in with the username and password entered.

i got the following error message:

Fatal error: Call to undefined method sfGuardUserPeer::retrieveByUsername() in /***/plugins/sfGuardPlugin/lib/validator/sfGuardValidatorUser.class.php on line 53

it looks quite weird to me, because the problematic part of sfGuardValidatorUser class looks like this:

// user exists?
if ($user = sfGuardUserPeer::retrieveByUsername($username))
{
  // password is ok?
  if ($user->getIsActive() && $user->checkPassword($password))
  {
    return array_merge($values, array('user' => $user));
  }
}

while sfGuardUserPeer has just the empty class:

class sfGuardUserPeer extends PluginsfGuardUserPeer
{
}

that extends PluginsfGuardUserPeer, so i checked it out too:

class PluginsfGuardUserPeer extends BasesfGuardUserPeer
{
  public static function retrieveByUsername($username, $isActive = true)
  {
    $c = new Criteria();
    $c->add(self::USERNAME, $username);
    $c->add(self::IS_ACTIVE, $isActive);

    return self::doSelectOne($c);
  }

}

that's the missing function!

so - what is wrong? why doesn't it work? i have already tried all the solutions found with google, but none of them work :/


Solution

  • finally found it!

    the

    symfony propel:build-model
    

    task unnecessarily generated the sfGuard classes in the model directory from the schema file located in the plugin directory, while all the classes were already present in the sfGuard folder.

    geez, that shouldn't happen in such a well-developed framework and plugin...