當前位置: 首頁>>代碼示例>>PHP>>正文


PHP sfGuardUser::getName方法代碼示例

本文整理匯總了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');
開發者ID:limitium,項目名稱:uberlov,代碼行數:31,代碼來源:PluginsfGuardUserTest.php

示例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);
 }
開發者ID:pierswarmers,項目名稱:rtCorePlugin,代碼行數:17,代碼來源:BasertGuardRegisterActions.class.php


注:本文中的sfGuardUser::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。