本文整理汇总了PHP中Team::to_array方法的典型用法代码示例。如果您正苦于以下问题:PHP Team::to_array方法的具体用法?PHP Team::to_array怎么用?PHP Team::to_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Team
的用法示例。
在下文中一共展示了Team::to_array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Team
function team_get()
{
// check that the id is at least a valid number
$this->_check_id();
// get the single team by id
$team = new Team();
$team->where('id', $this->get('id'))->limit(1)->get();
if ($team->result_count() == 1) {
$result = $team->to_array();
$members = new Membership();
// get members gives an actual object with ->profile_othervariable
$memb = $members->get_members($team->id);
// we have to select the user array manually because... we don't want to expose password hashes
foreach ($memb->all as $key => $mem) {
$result['members'][$key] = $mem->to_array(array('id', 'username'));
$result['members'][$key]['display_name'] = $mem->profile_display_name;
$result['members'][$key]['twitter'] = $mem->profile_twitter;
$result['members'][$key]['bio'] = $mem->profile_bio;
}
// all good
$this->response($result, 200);
// 200 being the HTTP response code
} else {
// no team for this id
$this->response(array('error' => _('Team could not be found')), 404);
}
}
示例2: Team
function team_get() {
if (!$this->get('id') || !is_numeric($this->get('id'))) {
$this->response(NULL, 400);
}
$team = new Team();
$team->where('id', $this->get('id'))->limit(1)->get();
if ($team->result_count() == 1) {
$result = $team->to_array();
$members = new Membership();
$memb = $members->get_members($team->id);
foreach($memb->all as $key => $mem) {
$result['members'][$key] = $memb->to_array(array('id','username'));
$result['members'][$key]['display_name'] = $memb->profile_display_name;
$result['members'][$key]['twitter'] = $memb->profile_twitter;
$result['members'][$key]['bio'] = $memb->profile_bio;
}
$this->response($result, 200); // 200 being the HTTP response code
} else {
$this->response(array('error' => _('Team could not be found')), 404);
}
}
示例3: Team
function team_get() {
if (!$this->get('id') || !is_numeric($this->get('id'))) {
$this->response(NULL, 400);
}
if (!$this->get('page') || !is_numeric($this->get('page')) || $this->get('page') < 1)
$page = 1;
else
$page = (int) $this->get('page');
$page = ($page * 100) - 100;
$team = new Team();
$team->where('id', $this->get('id'))->limit(1)->get();
if ($team->result_count() == 1) {
$result = array();
$result['team'] = $team->to_array();
// get joints to get also the chapters from joints
$joints = new Joint();
$joints->where('team_id', $team->id)->get();
$chapters = new Chapter();
$chapters->where('team_id', $team->id);
foreach ($joints->all as $joint) {
$chapters->or_where('joint_id', $joint->joint_id);
}
$chapters->limit(100, $page)->get();
$chapters->get_comic();
$result['chapters'] = array();
foreach ($chapters->all as $key => $chapter) {
if (!$chapter->team_id) {
$chapter->get_teams();
foreach ($chapter->teams as $item) {
$result['chapters'][$key]['teams'][] = $item->to_array();
}
} else {
$result['chapters'][$key]['teams'][] = $team->to_array();
}
$result['chapters'][$key]['comic'] = $chapter->comic->to_array();
$result['chapters'][$key]['chapter'] = $chapter->to_array();
}
$this->response($result, 200); // 200 being the HTTP response code
} else {
$this->response(array('error' => _('Team could not be found')), 404);
}
}
示例4: Team
/**
* Returns chapters per page from team ID
* Includes releases from joints too
*
* This is NOT a method light enough to lookup teams. use api/members/team for that
*
* Available filters: id (required), page, per_page (default:30, max:100), orderby
*
* @author Woxxy
*/
function team_get()
{
// get the single team by id or stub
if ($this->get('stub')) {
$team = new Team();
$team->where('stub', $this->get('stub'))->limit(1)->get();
} else {
// check that the id is at least a valid number
$this->_check_id();
$team = new Team();
$team->where('id', $this->get('id'))->limit(1)->get();
}
// team found?
if ($team->result_count() == 1) {
$result = array();
$result['team'] = $team->to_array();
// get joints to get also the chapters from joints
$joints = new Joint();
$joints->where('team_id', $team->id)->get();
$chapters = new Chapter();
// get all chapters with the team ID
$chapters->where('team_id', $team->id);
foreach ($joints->all as $joint) {
// get also all chapters with the joints by the team
$chapters->or_where('joint_id', $joint->joint_id);
}
// filter for the page and the order
$this->_orderby($chapters);
$this->_page_to_offset($chapters);
$chapters->get();
$chapters->get_comic();
// let's save some power by reusing the variables we already have for team
// and put everything in the usual clean [comic][chapter][teams]
$result['chapters'] = array();
foreach ($chapters->all as $key => $chapter) {
if (!$chapter->team_id) {
$chapter->get_teams();
foreach ($chapter->teams as $item) {
$result['chapters'][$key]['teams'][] = $item->to_array();
}
} else {
$result['chapters'][$key]['teams'][] = $team->to_array();
}
$result['chapters'][$key]['comic'] = $chapter->comic->to_array();
$result['chapters'][$key]['chapter'] = $chapter->to_array();
}
// all good
$this->response($result, 200);
// 200 being the HTTP response code
} else {
// that single team id wasn't found
$this->response(array('error' => _('Team could not be found')), 404);
}
}