操作失败后返回结果至客户端

@param string|array $message 提示信息
@param string|array $jumpUrl 页面跳转地址
@param mixed $data
- 为整数，则代表页面跳转停留时间，默认为3妙，时间结束后自动跳转至指定的`$jumpUrl`页面
- 为数组，则代表返回给客户端的数据

@return mixed
501959
public function error($message = '', $jumpUrl = '', $data = [])
    {
        return $this->getDispatch()->error($message, $jumpUrl, $data);
    }
917082
public function prettyMessage($message = null, $data = null)
    {
        $this->setMyMessage($message);
        $this->setMyData($data);


        return $this->template([
            'title' => $this->getMyTitle(),
            'message' => $this->getMyMessage(),
            'file' => $this->getMyFile(),
            'line' => $this->getMyLine(),
            'data' => $this->getMyData(),
            'traces' => $this->getMyTraces(),
            'footer' => $this->getMyFooter()
        ]);
    }
1164186
public function send(MessageInterface $message, $skipErrors = true) {

        // check clickatell limit
        if (count($message->getRecipients()) > 600) {
            $this->addError(new SendingError($message->getRecipients(),
                    'You have excedded provider limit of messages to send in one time.'
                    , $message->error));
        }

        $gateway = $this->getClient();

        try {
            $response = $gateway->sendMessage($message->getRecipients(), $message->getText());
            foreach ($response as $message) {
                if ($message->errorCode) {
                    $this->addError(new SendingError($message->destination, $message->errorCode, $message->error));
                }
            }
        }
        catch (Exception $e) {
            $this->addError(new SendingError('', $e->getCode(), $e->getMessage()));
            if (!$skipErrors) {
                throw new \RuntimeException($e->getMessage(), $e->getCode());
            }
        }
        return $this->getErrors()->count() === 0;
    }
503771
public function parseUrl($url, array $data)
    {
        return (empty($data)) ? $url : $url . '?' . $this->parseData($data);
    }
582917
public function send($url, $method = 'GET', $data = [])
    {
        $method = strtolower($method);

        $settings = [
            'headers'  => array_merge([
                'Authorization' => 'Bearer ' . $this->getToken(),
                'Content-Type' => 'application/x-www-form-urlencoded',
            ], $this->getHeaders()),
        ];

        if ($method == 'post') {
            $settings['form_params'] = $data;
        }

        return $this->client
            ->$method($url, $settings);
    }
1342051
public function mpsRedirect($data = [], $resultIsUrl = FALSE)
    {
        try {
            $this->debug->info(__FUNCTION__, 'Input Params: ' . json_encode($data));
            $movitelMps = new MovitelMps\MovitelMps($this->options);
            $movitelMps->setMovitelPublicKey($this->movitelPublicKey);
            $movitelMps->setMovitelPrivateKey($this->movitelPrivateKey);
            $movitelMps->setCpPublicKey($this->cpPublicKey);
            $movitelMps->setCpPrivateKey($this->cpPrivateKey);
            $dataToRequest = "SUB=" . $data['sub'] . "&REQ=" . $data['req'] . "&SOURCE=" . $data['source'] . "&SESS=" . $data['session_id'];
            $dataLink      = "PRO=" . $data['provider'] . "&CMD=" . $data['cmd_msisdn'] . "&SER=" . $data['service'] . "&SUB=" . $data['sub'] . "&DATA=";
            $this->debug->info(__FUNCTION__, '$dataToRequest: ' . json_encode($dataToRequest));
            $this->debug->info(__FUNCTION__, '$dataLink: ' . json_encode($dataLink));
            $dataRequest = $movitelMps->createDataRequestToMps($data, $dataToRequest);
            $this->debug->info(__FUNCTION__, '$dataRequest: ' . json_encode($dataRequest));
            if ($dataRequest !== NULL && is_array($dataRequest)) {
                $dataEncrypted = $dataRequest[0];
                $dataSignature = $dataRequest[1];
                // Link
                $movitelRedirectUrl = $data['link'] . self::MSISDN_METHOD . '?' . $dataLink . urlencode($dataEncrypted) . '&SIG=' . $dataSignature;
                $this->debug->info(__FUNCTION__, '$movitelRedirectUrl: ' . json_encode($movitelRedirectUrl));
                if ($resultIsUrl === TRUE) {
                    $this->debug->info(__FUNCTION__, 'Result is URL');

                    return [
                        'status' => 'url',
                        'link'   => $movitelRedirectUrl
                    ];
                } else {
                    $this->debug->info(__FUNCTION__, 'Result is Redirect');
                    // Redirect url
                    Utils::redirect($movitelRedirectUrl);
                }
            }
            $this->debug->info(__FUNCTION__, 'Invalid Redirect URL');
        }
        catch (\Exception $e) {
            $message = 'Error File: ' . $e->getFile() . ' - Line: ' . $e->getLine() . ' - Code: ' . $e->getCode() . ' - Message: ' . $e->getMessage();
            $this->debug->error(__FUNCTION__, $message);

            return NULL;
        }

        return NULL;
    }
1256833
public function request($method, $url, array $data = array(), array $extra = array())
    {
        switch (strtoupper($method)) {
            case 'POST':
                return $this->post($url, $data, $extra);
            case 'GET':
                return $this->get($url, $data, $extra);
            case 'PATCH':
                return $this->patch($url, $data, $extra);
            case 'HEAD':
                return $this->head($url, $data, $extra);
            case 'PUT':
                return $this->put($url, $data, $extra);
            case 'DELETE':
                return $this->delete($url, $data, $extra);
            default:
                throw new UnexpectedValueException(sprintf('Unsupported or unknown HTTP method provided "%s"', $method));
        }
    }
740589
public function send(MessageInterface $message, $skipErrors = true) {
        $this->clearErrors();

        $command = $this->prepareCommand($message->getText());

        foreach ($message->getRecipient() as $recipient) {
            // execute command
            $command = str_replace('#RECIPIENT#', $recipient, $command);

            $return = 0;
            $output = [];
            exec($command, $output, $return);

            if ($return !== 0) {
                $errorMsg = sprintf("Error while sending message to \"%s\".", $recipient);
                $this->addError(new SendingError($recipient, self::ERROR_NOT_SAVED, $errorMsg));
                if (!$skipErrors) {
                    throw new RuntimeException($errorMsg, self::ERROR_NOT_SAVED);
                }
            }
        }
        return $this->getErrors()->count() === 0;
    }
736629
public function returnSuccess($message = '操作成功', $url = '', $extra = [])
    {
        if (! empty($this->redirectRoute)) {
            $url = Url::toRoute([
                $this->redirectRoute,
                'msg' => $message,
                'url' => $url,
                $extra
            ]);
        }
        $this->redirect($url);
    }
1067824
public function success($message,$url='',$wait=3){
        $url=is_null($url) || $url=='' ? 'javascript:history.back(-1)' : $url;
        if($this->instance->isTemplateFile('success')){
            $this->instance->assign(['status'=>0,'message'=>$message,'url'=>url($url),'wait'=>$wait]);
            echo $this->instance->render('success');
            exit;
        }else{
            $status=true;
            require CORE_PATH.'tpl/jump.php';
            exit;
        }
    }
1108678
protected function buildUrl($url, array $data)
    {
        if (!$data) {
            return $url;
        }

        if (strpos($url, '?') === false) {
            $url .= '?';
        } elseif (substr($url, 0, -1) != '?') {
            $url .= '&';
        }

        return $url . http_build_query($data);
    }
959704
public function deserialize($data, AbstractMessage $message, array $options = [])
    {
        $this->sipe('content', 'setContent', $data, $message);

        if (isset($data['meta'])) {
            if (isset($data['meta']['updated'])) {
                $message->setModificationDate(DateNormalizer::denormalize($data['meta']['updated']));
            }

            if (isset($data['meta']['creator'])) {
                $message->setAuthor($data['meta']['creator']['name']);
                //_om is set by the trait
                $creator = $this->_om->getObject($data['meta']['creator'], User::class);

                if ($creator) {
                    $message->setCreator($creator);
                }
            }
        }

        return $message;
    }
987685
protected function error($msg = '', $url = '', $data = '', $wait = 3)
    {
        return $this->jump(0, $msg, $url, $data, $wait);
    }
586618
public function url($message = null)
    {
        $this->setRule(__FUNCTION__, function($val)
                       {
                           return (strlen(trim($val)) === 0 || filter_var($val, FILTER_VALIDATE_URL) !== FALSE);
                       }, $message);
        return $this;
    }
906283
private function exec($url, $data = '', $method = 'post', $header = [])
    {
        $res = false;
        $this->try = 0;
        $this->result = '';
        $this->action('start');

        while ($this->try < $this->tryMax) {
            $this->try++;
            $res = $this->realExec($url, $data, $method, $header);
            if ($res) {
                break;
            }
        }

        $this->action('stop');
        return $res;
    }
541201
public function get($url, array $data = array(), array $extra = array())
    {
        if (!empty($data)) {
            $url = $url . '?' . http_build_query($data);
        }

		$curl = new Curl(array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => false
        ), $extra);

        return $curl->exec();
    }
1219475
public function getSafeRedirectUrl($default, $data = null, $key = 'redirect') {
		$redirectUrl = $data ?: ($this->Controller->getRequest()->getData($key) ?: $this->Controller->getRequest()->getQuery($key));
		if ($redirectUrl && (mb_substr($redirectUrl, 0, 1) !== '/' || mb_substr($redirectUrl, 0, 2) === '//')) {
			$redirectUrl = null;
		}

		return $redirectUrl ?: $default;
	}