function profile2_from_user_context in Profile 2 7
Same name and namespace in other branches
- 7.2 plugins/relationships/profile2.inc \profile2_from_user_context()
Return a new context based on an existing context.
1 string reference to 'profile2_from_user_context'
- profile2.inc in plugins/
relationships/ profile2.inc - Plugin to provide an relationship handler for profile2 from user.
File
- plugins/
relationships/ profile2.inc, line 25 - Plugin to provide an relationship handler for profile2 from user.
Code
function profile2_from_user_context($context, $conf) {
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data) || !isset($context->data->uid)) {
return ctools_context_create_empty('entity:profile2', NULL);
}
// Load user's profile and return a ctools context from it.
if ($profile = profile2_load_by_user($context->data, $conf['type'])) {
return ctools_context_create('entity:profile2', $profile);
}
// In case when we can't load a profile, just return an empty context.
return ctools_context_create_empty('entity:profile2', NULL);
}