本文整理汇总了PHP中sfGuardUser::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardUser::getName方法的具体用法?PHP sfGuardUser::getName怎么用?PHP sfGuardUser::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardUser
的用法示例。
在下文中一共展示了sfGuardUser::getName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sfGuardUser
$tableGroup = Doctrine_Core::getTable('sfGuardGroup');
$tableGroup->createQuery()->delete()->where('name = ?', 'test-group')->execute();
$tablePermission = Doctrine_Core::getTable('sfGuardPermission');
$tablePermission->createQuery()->delete()->where('name = ?', 'test-permission')->execute();
$activeUser = new sfGuardUser();
$activeUser->first_name = 'John';
$activeUser->last_name = 'Doe';
$activeUser->email_address = 'email2@test.com';
$activeUser->username = 'active_user';
$activeUser->password = 'password';
$activeUser->is_active = true;
$activeUser->save();
// ->__toString()
$t->diag('output functions');
$t->is((string) $activeUser, 'John Doe (active_user)', '->__toString() returns the full name and the username');
$t->is($activeUser->getName(), 'John Doe', '->getName() returns the full name of the user');
// group managment
$t->diag('group managment');
$t->is($activeUser->getGroupNames(), array(), '->getGroupNames() return empty array if no group is set');
try {
$activeUser->addGroupByName('test-group');
$t->fail('->addGroupByName() does throw an exception if group not exist');
} catch (Exception $e) {
$t->pass('->addGroupByName() does throw an exception if group not exist');
}
$group = new sfGuardGroup();
$group->name = 'test-group';
$group->save();
$t->is($activeUser->hasGroup('test-group'), false, '->hasGroup() return false if user hasn\'t this group');
try {
$activeUser->addGroupByName('test-group');
示例2: notifyAdministrator
/**
* Notify the administrator of the pending user activation.
*
* @param sfGuardUser $user
*/
protected function notifyAdministrator(sfGuardUser $user)
{
$from = $user->getEmailAddress();
$to = $this->getAdminEmail();
$subject = sprintf('[%s] Registration request for: %s', $this->generateUrl('homepage', array(), true), $user->getName());
$body = 'A new user has registered but will need to be activated before they can sign in.' . "\n\n";
$body .= sprintf('The details they entered were: %s (%s)', $user->getName(), $user->getEmailAddress()) . "\n\n";
$body .= 'If you wish to automatically activate this user, you can do so by simply clicking on this link:' . "\n";
$body .= $this->generateUrl('sf_guard_register_confirm', array('id' => $user->getId()), true) . "\n\n";
$body .= 'Please note: you will need to be signed in to complete this action.' . "\n";
$this->getMailer()->composeAndSend($from, $to, $subject, $body);
}