编辑权限数据
@param array $data
@return $this
@throws Exception
179418
public function savePermission($data = [])
    {
        if (!empty($data)) {
            $this->data($data);
        }
        $validate = new \gmars\rbac\validate\Permission();
        if (!$validate->check($this)) {
            throw new Exception($validate->getError());
        }
        $data = $this->getData();
        if (isset($data['id']) && !empty($data['id'])) {
            $this->isUpdate(true);
        }
        $this->save();
        return $this;
    }
889175
public function setData(array $data): self
    {
        assert(count($data) == 2);

        [$allowedEvents, $subscribers] = $data;

        assert($this->checkAllSubscribersAreStatic($subscribers) === true);

        return $this->setAllowedEvents($allowedEvents)->setSubscribers($subscribers);
    }
349206
public function passMany(array $data)
    {
        if (!isset($this->_session))
            throw new \Exception('m\Http\Response: No session object available to flash "'.$key.'" to.');

        $this->_session->flashMany($data);

        return $this;
    }
1288732
public function setData(array $data) {
		$this->data = $data;

		$this->resetFields();

		foreach($data as $name=>$data)
			$this->newField($name, $data);

		$this->updateChilds();

		return $this;
	}
182828
public function create(array $data): Model
    {
        $result = $this->repo->create($data);
        $pid = empty($data['pid']) ? 0 : $data['pid'];


        if ((int)$pid !== 0) {
            // 计算根id
            $parent = $this->show($data['pid']);
            $rootId = $parent->root_id;
            // 计算深度
            $deep = (int)$parent->deep + 1;
            // 计算path
            $path = $parent->path . $result->id . ",";
        } else {
            // 计算根id
            $rootId = $result->id;
            // 计算深度
            $deep = 0;
            // 计算path
            $path = "," . $result->id . ",";
        }

        /*
         | 将根id和分类深度写回去
         | 使用save方法
         */
        $result->root_id = $rootId;
        $result->deep = $deep;
        $result->path = $path;
        if (! $result->save()) {
            throw new CommodityCateException("商品分类没有添加成功", ExceptionCode::CREATED_FAILURE);
        }

        return $result;
    }
1036680
public function setData(array $data)
    {
        foreach ($data as $key => $val) {
            $setter = $this->setter($key);
            if (is_callable([ $this, $setter ])) {
                $this->{$setter}($val);
            } else {
                $this->{$key} = $val;
            }
        }

        return $this;
    }
423780
public function setData(array $data)
    {
        foreach ($data as $prop => $val) {
            $func = [$this, $this->setter($prop)];
            if (is_callable($func)) {
                call_user_func($func, $val);
            } else {
                $this->{$prop} = $val;
            }
        }

        return $this;
    }
609940
public function data(array $data)
    {
        foreach ($data as $name => $rows) {
            // 允许直接传入文案，不传颜色，如 ['first' => '恭喜你购买成功！']
            if (!is_array($rows)) {
                $data[$name] = ['value' => $rows];
            }

            // 空值则显示默认值
            if ($name !== 'remark' && !$this->wei->isPresent($data[$name]['value'])) {
                $data[$name]['value'] = '-';
            }
        }

        $this->request['data'] = $data;

        return $this;
    }
205941
public function copyFrom($data)
    {
        if (is_array($data) || ($data instanceof \Traversable)) {
            if ($this->_count > 0) {
                $this->clear();
            }
            if ($data instanceof CList) {
                $data = $data->_data;
            }
            foreach ($data as $item) {
                $this->push($item);
            }
        } elseif ($data !== null) {
            throw new Exception('实例化列表参数必须是数组或可遍历的对象', 100100501);
        }
    }
694610
public function setData($data) 
	{
		if(is_array($data)) {
			$this->data = $data;
		}
		
		$args = func_get_args();
		$this->data[$args[0]] = $args[1];
		
		return $this;
	}
1253975
public function data(array $data)
    {
        if (!is_array($this->props['data'])) $this->props['data'] = [];
        $this->props['data'] = array_merge($this->props['data'], $data);
        return $this;
    }
714477
public function setData($data = [])
    {
        $this->data = $data;
        $this->debug->info(__FUNCTION__, 'setData: ', $this->data);

        return $this;
    }
525076
public function copyFrom($data)
    {
        if (is_array($data) || $data instanceof \Traversable) {
            if ($this->getCount() > 0) {
                $this->clear();
            }
            if ($data instanceof CMap) {
                $data = $data->_data;
            }
            foreach ($data as $key => $value) {
                $this->add($key, $value);
            }
        } elseif ($data !== null) {
            throw new Exception('实例化列表参数必须是数组或可遍历的对象', 100100601);
        }
    }
708099
public function setData(array $data)
    {
        if (count($data)) {
            $data = array_combine($data, $data);
        }

        $this->_data = $data;

        return $this;
    }
366333
public function setData(array $data): self
    {
        $this->data = \array_merge($this->data, $data);

        return $this;
    }
633983
public function send($data)
    {
        $token = $this->grantToken();
        $newData = $data;
        foreach($token as $k=>$v) {
            $newData[$k] = $v;
        }

        //必填 消息发送类型,其值为unicast,listcast,broadcast,groupcast或customizedcast
        if(!isset($data['type'])) {
            throw new Exception('need param: type');
        }

        // 可选 当type=customizedcast时,开发者填写自己的alias,友盟根据alias进行反查找,得到对应的device_token。多个alias时用英文逗号分,不能超过50个。
        if(isset($data['alias']) && !empty($data['alias'])) {
            if(is_array($data['alias'])) {
                $newData['alias'] = implode(',', $data['alias']);
            } else {
                $newData['alias'] = $data['alias'];
            }
        }

        // 必填 消息类型，值为notification或者message
        if(!isset($data['payload']['display_type'])) {
            $newData['payload']['display_type'] = 'notification';
        }

        // 必填 通知栏提示文字。但实际没有用，todo确认
        if(!isset($data['payload']['body']['ticker'])) {
            $newData['payload']['body']['ticker'] = $data['payload']['body']['title'];
        }

        //可选 消息描述。用于友盟推送web管理后台，便于查看。
        if(!isset($data['description'])) {
            $newData['description'] = $data['payload']['body']['title'];
        }
        
        $defaultTrueParams = array(
            // 通知到达设备后的提醒方式
            'play_vibrate', // 可选 收到通知是否震动,默认为"true".注意，"true/false"为字符串
            'play_lights',  // 可选 收到通知是否闪灯,默认为"true"
            'play_sound',   // 可选 收到通知是否发出声音,默认为"true"
        );

        foreach($defaultTrueParams as $one) {
            if(isset($data['payload']['body'][$one]) && ($data['payload']['body'][$one] == false || $data['payload']['body'][$one] == 'false')) {
                $newData['payload']['body'][$one] = 'false';
            }
        }

        $http = new \HTTPRequest($this->conf['api_uri_prefix'] . 'api/send', HTTP_METH_POST);
        $http->setBody(json_encode($newData));
        $http->send();
        $body = $http->getResponseBody();
        if($http->getResponseCode() != 200) {
            throw new Exception($body);
        }
        $tmp = json_decode($body, true);

        if(!isset($tmp['ret']) || $tmp['ret'] != 'SUCCESS') {
            throw new Exception($body);
        }
        return true;
    }
916227
public function update(array $data)
    {
        $where = [];
        $options = $this->parseExpress();
        $data    = array_merge($options['data'], $data);
        if (isset($options['cache']) && is_string($options['cache']['key'])) {
            $key = $options['cache']['key'];
        }
        $pk = $this->getPk();
        if (empty($options['where'])) {
            // 如果存在主键数据 则自动作为更新条件
            if (is_string($pk) && isset($data[$pk])) {
                $where[$pk] = $data[$pk];
                $key        = 'mongo:' . $options['table'] . '|' . $data[$pk];
                unset($data[$pk]);
            } elseif (is_array($pk)) {
                // 增加复合主键支持
                foreach ($pk as $field) {
                    if (isset($data[$field])) {
                        $where[$field] = $data[$field];
                    } else {
                        // 如果缺少复合主键数据则不执行
                        throw new Exception('miss complex primary data');
                    }
                    unset($data[$field]);
                }
            }
            if (!isset($where)) {
                // 如果没有任何更新条件则不执行
                throw new Exception('miss update condition');
            } else {
                $options['where']['$and'] = $where;
            }
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['$and'][$pk])) {
            $key = $this->getCacheKey($options['where']['$and'][$pk], $options);
        }

        // 生成bulkWrite对象
        $bulk         = $this->builder->update($data, $options);
        $writeConcern = isset($options['writeConcern']) ? $options['writeConcern'] : null;
        $writeResult  = $this->execute($options['table'], $bulk, $writeConcern);

        $result = $writeResult->getModifiedCount();
        if ($result) {
            if (isset($where[$pk])) {
                $data[$pk] = $where[$pk];
            } elseif (is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                unset($a);
                $data[$pk]     = $val;
            }
            $options['data'] = $data;
            $this->trigger('after_update', $options);
        }
        return $result;
    }