Yii Framework Forum: chapter 7, CUserIdentity pg 167 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

chapter 7, CUserIdentity pg 167

#1 User is offline   digitalzombie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 19-August 10

Posted 14 October 2010 - 10:17 AM

Quote

"...is that id just happens to be an explicitly defined property on the CUserIdentity class. So, other than name and id..." pg 167


I've looked at the CUserIdentity class, name and id are not explicitly defined properties (as in class variables).

Edit:

I've just looked at it again. I think you misworded it? They're actually defined methods? Or am I wrong?

Code in the CUserIdentity class.
	public function getId()
	{
		return $this->username;
	}

	public function getName()
	{
		return $this->username;
	}



Looking at it over again, I believe you just overloaded the getId function.

Edit:

Quote

The reason we take a different approach...pg167


Different approach? What was the other previous approaches we have done?
<-- sorry I jumped the gun on that one

-------------------


Oh, I got it now. I guess you were trying to say that since the parent class have a function getId, we've just have to overload it in the child. Whereas the lastLoginTime is different because the parent class doesn't have a function for this, so we had to add it to session.

Am I correct in my assessment?
0

#2 User is offline   jefftulsa 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 168
  • Joined: 06-October 08
  • Location:Austin, TX

Posted 14 October 2010 - 04:59 PM

Yes, this is more or less on the right track. I agree better phrasing could have been used.

The basic idea is that the reason that we use different approaches to save id and lastLoginTime is because id is already a pre-defined property that is recognized by CWebUser (and it is set by an explicit call to the getId() method of the Identity class during login). If we want to store information beyond id and name, then we need to use setState(), as was done with lastLoginTime.

Hope this helps, and sorry for any confusion.
0

#3 User is offline   digitalzombie 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 19-August 10

Posted 15 October 2010 - 10:11 AM

View Postjefftulsa, on 14 October 2010 - 04:59 PM, said:

Yes, this is more or less on the right track. I agree better phrasing could have been used.

The basic idea is that the reason that we use different approaches to save id and lastLoginTime is because id is already a pre-defined property that is recognized by CWebUser (and it is set by an explicit call to the getId() method of the Identity class during login). If we want to store information beyond id and name, then we need to use setState(), as was done with lastLoginTime.

Hope this helps, and sorry for any confusion.


Thank you ^^.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users