本文整理汇总了PHP中ElggUser::getExternalAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggUser::getExternalAttributes方法的具体用法?PHP ElggUser::getExternalAttributes怎么用?PHP ElggUser::getExternalAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggUser
的用法示例。
在下文中一共展示了ElggUser::getExternalAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sourceToEntity
/**
* Hook to transform a search result to an Elgg Entity
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param Client $returnvalue current return value
* @param array $params supplied params
*
* @return void|Client
*/
public static function sourceToEntity($hook, $type, $returnvalue, $params)
{
$hit = elgg_extract('hit', $params);
$index = elgg_extract('_index', $hit);
$elgg_index = elasticsearch_get_setting('index');
if ($index !== $elgg_index) {
return;
}
$source = elgg_extract('_source', $hit);
$row = new \stdClass();
foreach ($source as $key => $value) {
switch ($key) {
case 'subtype':
// elastic stores the textual version of the subtype, entity_row_to_elggstar needs the int
$row->{$key} = get_subtype_id($source['type'], $value);
break;
case 'last_action':
case 'time_created':
case 'time_updated':
// convert the timestamps to unix timestamps
$value = strtotime($value);
default:
$row->{$key} = $value;
break;
}
}
// enabled attribute is not stored in elasticsearch by default
$row->enabled = 'yes';
// specials types
if ($row->type == 'user') {
// makes sure all attributes are loaded to prevent a db call
$external_attributes = \ElggUser::getExternalAttributes();
foreach ($external_attributes as $key => $value) {
if (isset($row->{$key})) {
continue;
}
$row->{$key} = $value;
}
}
try {
$result = entity_row_to_elggstar($row);
} catch (\Exception $e) {
elgg_log($e->getMessage(), 'NOTICE');
return;
}
return $result;
}