本文整理汇总了PHP中Foundry::json方法的典型用法代码示例。如果您正苦于以下问题:PHP Foundry::json方法的具体用法?PHP Foundry::json怎么用?PHP Foundry::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Foundry
的用法示例。
在下文中一共展示了Foundry::json方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPhotoFromParams
/**
* Retrieve the table object from the stream item params
*
* @since 1.2
* @access public
* @param string
* @return
*/
public function getPhotoFromParams(SocialStreamItem &$item, $privacy = null)
{
if (count($item->contextIds) > 0 && $item->verb != 'uploadAvatar' && $item->verb != 'updateCover') {
$photos = array();
// We only want to get a maximum of 5 photos if we have more than 1 photo to show.
$ids = array_reverse($item->contextIds);
$i = 0;
foreach ($ids as $id) {
if ($i >= 5) {
break;
}
$photo = Foundry::table('Photo');
$raw = isset($item->contextParams[$id]) ? $item->contextParams[$id] : '';
if ($raw) {
$obj = Foundry::json()->decode($raw);
$photo->bind($obj);
if (!$photo->id) {
$photo->load($id);
}
} else {
$photo->load($id);
}
// Determine if the user can view this photo or not.
if (!$item->cluster_id && $privacy->validate('photos.view', $photo->id, SOCIAL_TYPE_PHOTO, $item->actor->id)) {
$photos[] = $photo;
} else {
if ($item->cluster_id) {
$photos[] = $photo;
}
}
$i++;
}
return $photos;
}
// Load up the photo object
$photo = Foundry::table('Photo');
// Get the context id.
$id = $item->contextId;
$raw = isset($item->contextParams[$id]) ? $item->contextParams[$id] : '';
if ($raw) {
$obj = Foundry::json()->decode($raw);
$photo->bind($obj);
if (!$photo->id) {
$photo->load($id);
}
return $photo;
}
$photo->load($id);
return $photo;
}