Created
July 15, 2009 06:55
-
-
Save jawngee/147549 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* Provides a 'profile' property that returns the current user's profile: | |
* | |
* <code> | |
* if ($session->profile) | |
* echo $session->profile->name; | |
* </code> | |
*/ | |
class MassifySession extends Session | |
{ | |
// The user's profile model | |
private $_profile=null; | |
/** | |
* Callback method for getting a property | |
*/ | |
function __get($prop_name) | |
{ | |
switch($prop_name) | |
{ | |
case 'profile': | |
if (!isset($this->data['pid'])) | |
return null; | |
if (!$this->_profile) | |
$this->_profile=new Profile($this->data['pid']); | |
return $this->_profile; | |
} | |
return parent::__get($prop_name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment