当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayHelper::toarray方法代码示例

本文整理汇总了PHP中yii\helpers\ArrayHelper::toarray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::toarray方法的具体用法?PHP ArrayHelper::toarray怎么用?PHP ArrayHelper::toarray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\helpers\ArrayHelper的用法示例。


在下文中一共展示了ArrayHelper::toarray方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ParentsMap

 /**
  * 父亲菜单Map
  */
 public function ParentsMap()
 {
     $parentMenus = self::findAll(['menu_show' => 1, 'parent_id' => 0]);
     $parentMenus = ArrayHelper::toarray($parentMenus);
     $parentMenus = ArrayHelper::map($parentMenus, 'menu_id', 'menu_name');
     $parentMenus[0] = '父级菜单';
     return $parentMenus;
 }
开发者ID:songhongyu,项目名称:datecenter,代码行数:11,代码来源:Menu.php

示例2: actionView

 /**
  * Views help desk issue and its activities.
  *
  * <b>Request Type</b>: GET<br/><br/>
  * <b>Request Endpoint</b>:http://{server-domain}/api/chat/issue/{id}<br/><br/>
  * <b>Content-type</b>: application/json<br/><br/>
  * <b>Summary</b>: This api is used for help desk to view issue and corresponding activities.
  * <br/><br/>
  *
  * <b>Request Params</b>:<br/>
  *     accesstoken: string, the access token<br/>
  *     <br/><br/>
  *
  * <b>Response Params:</b><br/>
  *     return issue detail and its all related activities and attachements, if success,
  *     ortherwise, throw an invalid parameters exception.<br/>
  *     <br/><br/>
  *
  * <b>Request Example:</b><br/>
  * <pre>
  * {
  *     "accesstoken" : "eeaa31a8-1d55-247e-70a2-bc9af23918ec",
  *     "id": "55c446c60faf303f0b8b456a"
  * }
  * </pre>
  * <br/><br/>
  *
  * <b>Response Example</b>:<br/>
  * <pre>
  * {
  *  "issue": {
  *    "id": "55c72d5e0faf308f048b4567",
  *    "title": "测试Function CreateActivity--2",
  *    "description": "如果成功返回结果ok",
  *    "status": "resolved",
  *    "creator": {
  *         "id": "55c446c60faf303f0b8b456a",
  *         "name": "byronzhang",
  *         "email": "byronzhang@quncrm.com"
  *         "avatar": "http://vincenthou.qiniudn.com/52a82080e78c991bc0ca3d3a.png"
  *         ...
  *    },
  *    "assignee": null,
  *    "createdAt": 1439116638125,
  *    "attachments": [
  *    {
  *        "id": "55cc90d70faf30e21a8b4573",
  *        "name": "195750372",
  *        "type": "image/jpeg",
  *        "size": "0.01",
  *        "url": "http://vincenthou.qiniudn.com/4f8dd288bc5291273c91d43d.jpg",
  *        ...
  *    }],
  *    "activities": [
  *    {
  *      "id": "55c72d5e0faf308f048b4568",
  *      "creator": {
  *         "id": "55c446c60faf303f0b8b456a",
  *         "name": "byronzhang",
  *         "email": "byronzhang@quncrm.com"
  *         "avatar": "http://vincenthou.qiniudn.com/52a82080e78c991bc0ca3d3a.png"
  *         ...
  *      },
  *      "action": "create",
  *      "description": "测试Function CreateActivity",
  *      "createdAt": 1439116638254
  *    },
  *    {
  *      "id": "55c72e2f0faf3090048b4568",
  *      "creator": {
  *         "id": "55c446c60faf303f0b8b456a",
  *         "name": "byronzhang",
  *         "email": "byronzhang@quncrm.com"
  *         "avatar": "http://vincenthou.qiniudn.com/52a82080e78c991bc0ca3d3a.png"
  *         ...
  *      },
  *      "action": "claim",
  *      "description": "",
  *      "createdAt": 1439116638254,
  *    }
  *  ]
  *}
  * </pre>
  */
 public function actionView($id)
 {
     $issue = Issue::findByPk($id);
     if (empty($issue)) {
         throw new InvalidParameterException(['issue' => Yii::t('issue', 'issue_id_does_not_exist')]);
     }
     $issue->creator = $issue->creatorDetail;
     $issue->assignee = $issue->assigneeDetail;
     $activities = $issue->activities;
     foreach ($activities as $activity) {
         $activity->creator = $activity->creatorDetail;
     }
     $result = array_merge(ArrayHelper::toarray($issue), ['attachments' => $issue->attachments, 'activities' => $issue->activities]);
     return $result;
 }
开发者ID:timelessmemory,项目名称:uhkklp,代码行数:99,代码来源:IssueController.php


注:本文中的yii\helpers\ArrayHelper::toarray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。