class AuthcacheUserSetting in Authenticated User Page Caching (Authcache) 7.2
Setting handler for profile data of currently logged in user.
Hierarchy
- class \AuthcacheUserSetting implements AuthcacheP13nSettingInterface
Expanded class hierarchy of AuthcacheUserSetting
1 string reference to 'AuthcacheUserSetting'
- authcache_user_authcache_p13n_setting in modules/
authcache_user/ authcache_user.module - Implements hook_authcache_p13n_setting().
File
- modules/
authcache_user/ includes/ AuthcacheUserSetting.inc, line 10 - Defines setting handler for profile data of currently logged in user.
View source
class AuthcacheUserSetting implements AuthcacheP13nSettingInterface {
protected $properties;
/**
* Construct new personalized user setting handler.
*/
public function __construct(array $properties) {
$this->properties = drupal_map_assoc($properties);
}
/**
* Return profile data of currently logged in user.
*/
public function get($params, $context) {
$data = $this
->getUserData();
return $this
->escapeUserData($data);
}
/**
* Load and prepare an array of properties of the currently logged in user.
*/
protected function getUserData() {
global $user;
$data = (array) $user;
unset($data['pass']);
return array_intersect_key($data, $this->properties);
}
/**
* Escape user data such that it can be savely displayed by the browser.
*/
protected function escapeUserData(array $data) {
array_walk_recursive($data, function (&$value) {
$value = check_plain($value);
});
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AuthcacheUserSetting:: |
protected | property | ||
AuthcacheUserSetting:: |
protected | function | Escape user data such that it can be savely displayed by the browser. | |
AuthcacheUserSetting:: |
public | function |
Return profile data of currently logged in user. Overrides AuthcacheP13nSettingInterface:: |
|
AuthcacheUserSetting:: |
protected | function | Load and prepare an array of properties of the currently logged in user. | |
AuthcacheUserSetting:: |
public | function | Construct new personalized user setting handler. |