本文整理汇总了PHP中Profile::setUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Profile::setUser方法的具体用法?PHP Profile::setUser怎么用?PHP Profile::setUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Profile
的用法示例。
在下文中一共展示了Profile::setUser方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerUser
private function registerUser($username, $data = NULL)
{
try {
$gingerKey = sfConfig::get('app_portail_ginger_key');
if ($gingerKey != "abc") {
$ginger = new \Ginger\Client\GingerClient(sfConfig::get('app_portail_ginger_key'));
$cotisants = $ginger->getUser($username);
} else {
$cotisants = new stdClass();
$cotisants->mail = $username . "@etu.utc.fr";
$cotisants->prenom = "Le";
$cotisants->nom = "Testeur";
$cotisants->type = "etu";
}
if (!$data) {
$data = new sfGuardUser();
}
$data->setUsername($username);
$data->setEmailAddress($cotisants->mail);
$data->setFirstName($cotisants->prenom);
$data->setLastName($cotisants->nom);
$data->setIsActive(true);
$data->save();
$profile = new Profile();
$profile->setUser($data);
$profile->setDomain($cotisants->type);
$profile->save();
return $data;
} catch (\Ginger\Client\ApiException $ex) {
$this->setFlash('error', "Il n'a pas été possible de vous identifier. Merci de contacter simde@assos.utc.fr en précisant votre login et le code d'erreur " . $ex->getCode() . ".");
}
return false;
}
示例2: getProfile
public function getProfile()
{
if (!$this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
throw new \LogicException("Can't get profile of a non-authenticated user.");
}
$user = $this->securityContext->getToken()->getUser();
$repo = $this->em->getRepository('ZzPyroBundle:Profile');
$profile = $repo->findOneByUser($user);
if ($profile === null) {
$profile = new Profile();
$profile->setUser($user);
$this->em->persist($profile);
}
return $profile;
}
示例3: anyCreate
/**
* Create
*/
public function anyCreate()
{
$user = new User();
$profile = new Profile();
// process POST
if ($_POST) {
// check for valid data
// typecast to prevent error (if there are no profile fields)
$userValidate = $user->fillValidateAdminCreate(Input::get("User"));
$profileValidate = $profile->fillValidateAdminCreate((array) Input::get("Profile"));
if ($userValidate and $profileValidate) {
$user->save();
$profile->setUser($user->id)->save();
// set success and reload page
Session::flash("success", $user);
return Redirect::to(Request::path());
}
}
return View::make("admin.create", array("user" => $user, "profile" => $profile));
}
示例4: _register
/**
* Register new user
* @param User $user
* @param Profile $profile
* @return bool
*/
protected function _register($user, $profile)
{
// set up user and profile
$roleId = Role::USER;
$status = User::STATUS_ACTIVE;
if (Config::get("auth.emailActivation")) {
$status = User::STATUS_INACTIVE;
$user->generateToken();
}
$user->setDefaults($roleId, $status)->save();
$profile->setUser($user->id)->save();
// generate activation key and send email
if (Config::get("auth.emailActivation")) {
// send email
$data["user"] = $user;
$count = Mail::send(Config::get("auth.emailViewPath") . ".activate", $data, function ($message) use($user, $profile) {
$message->to($user->email, $user->username)->subject("Activate your new account");
});
} else {
Auth::login($user);
}
}
示例5: getUser
function getUser()
{
if (is_null($this->UserID)) {
return parent::getUser();
}
if (is_null(parent::getUser()) && $this->UserID) {
parent::setUser(Outlet::getInstance()->load('User', $this->UserID));
}
return parent::getUser();
}