Skip to content

Instantly share code, notes, and snippets.

@jawngee
Created July 15, 2009 06:55
Show Gist options
  • Save jawngee/147549 to your computer and use it in GitHub Desktop.
Save jawngee/147549 to your computer and use it in GitHub Desktop.
<?
/**
* 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