批量设置Session的值

@param   array   $data
@throws  \ErrorException
492143
public static function setBatch(array $data)
    {
        Base::checkOpen();
        if (Base::driver() == "file") {
            $_SESSION = $data;
            return;
        }
        self::removeAll();
        $session = Base::getSessionObject();
        foreach ($data as $index => $value) {
            $session->set($index, $value);
        }
    }
1040810
public function sendMessage(array $data)
    {
        $result = $this->httpRaw(self::WECHAT_MESSAGE_SEND_PREFIX, $data, [
            'access_token' => $this->getAccessToken()
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok' ? $result : $this->dump([self::WECHAT_BASE_URL . self::WECHAT_MESSAGE_SEND_PREFIX, $this->getAccessToken(), $data, $result]);
    }
971851
public function updateIndexOne(array $data)
    {
        if (!is_array($data)) {
            throw new \Exception('你的索引参数不是一个数组');
        }

        if (count($data) == count($data, 1)) {
            // 一维数组
            $this->getIndex()->update(new \XSDocument($data));
        }

        //索引是否立即生效
        if ($this->flush_index) {
            $this->getIndex()->flushIndex();
        }

        return $this->getIndex();
    }
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);
        }
    }
61922
public function setData(array $data): void {
		if ($this->compiled) {
			throw new ViewException("Attempt to alter view after compilation.", ViewException::AFTER_COMPILE_ALTERATION);
		}
		// to avoid overwriting any data that has already been set
		// using setDatum(), we don't want to do a simple assignment.
		// instead, we'll more carefully copy information from $data
		// to the data property.
		
		foreach ($data as $index => $datum) {
			$this->setDatum($index, $datum);
		}
	}
134857
public function delete($data = null)
    {
        // 分析查询表达式
        $options = $this->parseExpress();
        $pk      = $this->getPk($options);
        if (isset($options['cache']) && is_string($options['cache']['key'])) {
            $key = $options['cache']['key'];
        }

        if (!is_null($data) && true !== $data) {
            if (!isset($key) && !is_array($data)) {
                // 缓存标识
                $key = 'think:' . $options['table'] . '|' . $data;
            }
            // AR模式分析主键条件
            $this->parsePkWhere($data, $options);
        } elseif (!isset($key) && is_string($pk) && isset($options['where']['AND'][$pk])) {
            $key = $this->getCacheKey($options['where']['AND'][$pk], $options, $this->bind);
        }

        if (true !== $data && empty($options['where'])) {
            // 如果条件为空 不进行删除操作 除非设置 1=1
            throw new Exception('delete without condition');
        }
        // 生成删除SQL语句
        $sql = $this->builder->delete($options);
        // 获取参数绑定
        $bind = $this->getBind();
        if ($options['fetch_sql']) {
            // 获取实际执行的SQL语句
            return $this->connection->getRealSql($sql, $bind);
        }

        // 执行操作
        $result = $this->execute($sql, $bind);
        if ($result) {
            if (!is_array($data) && is_string($pk) && isset($key) && strpos($key, '|')) {
                list($a, $val) = explode('|', $key);
                unset($a);
                $item[$pk]     = $val;
                $data          = $item;
            }
            $options['data'] = $data;
            $this->trigger('after_delete', $options);
        }
        return $result;
    }
834865
public function notify(array $data = null)
    {
        if(is_null($data)) {
            $data = $_POST;
        }

        if(!$this->verifyResponse($data)) {
            throw new \Exception('回调参数签名不正确');
        }

        try {
            switch($data['status']) {
                case static::NOTIFY_STATUS_CANCELED:
                    $result = $this->notifyHandler->handleCanceled($data);
                    break;
                default:
                    $result = $this->notifyHandler->handlePaid($data);
            }

            if($result === false) {
                throw new \RuntimeException('notify failed');
            }

            return $this->success();
        } catch (\Exception $e) {
            return $this->failed();
        }
    }
133571
public function setSession($data, ...$args)
    {
        if (is_array($data)) {
            // @codeCoverageIgnoreStart
            if (isset($_SESSION) && $data !== $_SESSION) {
                $_SESSION = $data;
            }
            // @codeCoverageIgnoreEnd

            return $this->set('session', $data);
        }

        if (count($args) === 0) {
            return $this;
        }

        $this->set('session', $data, ...$args);

        // @codeCoverageIgnoreStart
        if (isset($_SESSION) && $data !== $_SESSION) {
            $_SESSION = $this->get('session');
        }
        // @codeCoverageIgnoreEnd

        return $this;
    }
763150
protected function validate(array $data, array $rules = null): void
    {
        $validator = $this->validatorFactory->make($data, $rules ?? $this->getValidationRules());
        if ($validator->fails()) {
            throw new ValidationException($validator);
        }
    }
436335
private function hydrate($data = array()) {
        foreach ($data as $key => $value) {
            $method = "set" . ucfirst($key);
            if (method_exists($this, $method)) {
                call_user_func(array($this, $method), $value);
            }
        }
    }
175865
public function mergeWith($data)
    {
        if (is_array($data) || ($data instanceof \Traversable)) {
            if ($data instanceof CList) {
                $data = $data->_data;
            }
            foreach ($data as $item) {
                $this->push($item);
            }
        } elseif ($data !== null) {
            throw new Exception('列表合并参数必须是数组或可遍历的对象', 100100502);
        }
    }
782976
public function init(array $data = [])
    {
        foreach ($data as $key => $value) {
            $key = $this->getPreparedKey($key);
            $method = 'set' . str_replace(' ', '', $key);

            if (method_exists($this, $method)) {
                $this->{$method}($value);
            }
        }
    }
1138315
protected function validate(array $data)
    {
        $validator = Validator::make($data, $this->rules);

        if ($validator->fails()) {
            throw new FormValidationException(trans('dashboard::dashboard.errors.form.validation'), $validator);
        }
    }
975866
public function failed(array $data)
	{
		$handler = $this->dispatcher->resolveHandler($command = unserialize($data['command']));

		if (method_exists($handler, 'failed'))
		{
			call_user_func([$handler, 'failed'], $command);
		}
	}
911039
public function setData($data = [])
    {
        if (!is_array($data) && is_string($data)) {
            $data = parse_str($data);
        }
        if (count($data) == 0) {
            $this->data = [];
        } else {
            $this->data = $data;
        }
        $this->debug->debug(__FUNCTION__, 'Data into Request: ', $this->data);
    }
519206
public function set($data): Record
    {
        //可以以SRow格式或数组格式提供数据
        if ($data instanceof Row) {
            $this->_data = $data->all();
        } elseif (is_array($data)) {
            $this->_data = $data;
        } elseif ($data) {
            $this->loadByPk($data);
        }

        //保存原始数据
        $this->_old = $this->_data;

        //执行读取数据后的钩子
        if ($this->_data) {
            $this->_data = $this->afterLoad($this->_data);
        }

        //将原始值赋值给属性
        if ($data) {
            foreach ($this->_data as $k => $v) {
                $this->$k = $v;
            }
        }
        return $this;
    }
1081906
public function addIndex(array $data)
    {
        if (!is_array($data)) {
            throw new \Exception('你的索引参数不是一个数组');
        }
        if (isset($data[0]) && is_array($data[0])) {
            // 多维数组
            foreach ($data as $v) {
                $this->getIndex()->add(new \XSDocument($v));
            }
        } else {
            // 一维数组
            $this->getIndex()->add(new \XSDocument($data));
        }
        //索引是否立即生效
        if ($this->flush_index) {
            $this->getIndex()->flushIndex();
        }
        return $this->getIndex();
    }