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


PHP Response::create方法代码示例

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


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

示例1: testReceiveSignalRequestLogger

 public function testReceiveSignalRequestLogger()
 {
     $result = 'phpunit_' . mt_rand();
     $response = new Response();
     $response->create(200, $result);
     $this->mockTest->receiveSignalRequestLogger("http://notexistdomain.com", null, 'GET', $response);
     $this->assertEquals($result, $this->mockTest->responseRawResult);
 }
开发者ID:HorseLuke,项目名称:QcloudApi-SDK-PHP,代码行数:8,代码来源:CurlRequestLoggerInterfaceTest.php

示例2: submit

 public function submit()
 {
     if ($this->validateAction()) {
         $comments = $this->request->request('comments');
         $comments = is_string($comments) ? trim($comments) : '';
         if ($comments === '' && $this->app->make('config')->get('concrete.misc.require_version_comments')) {
             return Response::create(t('Please specify the version comments'), 400);
         }
         $c = $this->page;
         $u = new User();
         $v = CollectionVersion::get($c, "RECENT");
         $v->setComment($_REQUEST['comments']);
         $pr = new PageEditResponse();
         if (($this->request->request->get('action') == 'publish' || $this->request->request->get('action') == 'schedule') && $this->permissions->canApprovePageVersions()) {
             $e = $this->checkForPublishing();
             $pr->setError($e);
             if (!$e->has()) {
                 $pkr = new ApprovePagePageWorkflowRequest();
                 $pkr->setRequestedPage($c);
                 $pkr->setRequestedVersionID($v->getVersionID());
                 $pkr->setRequesterUserID($u->getUserID());
                 $u->unloadCollectionEdit($c);
                 if ($this->request->request->get('action') == 'schedule') {
                     $dateTime = new DateTime();
                     $publishDateTime = $dateTime->translate('check-in-scheduler');
                     $pkr->scheduleVersion($publishDateTime);
                 }
                 if ($c->isPageDraft()) {
                     $pagetype = $c->getPageTypeObject();
                     $pagetype->publish($c, $pkr);
                 } else {
                     $pkr->trigger();
                 }
             }
         } else {
             if ($this->request->request->get('action') == 'discard') {
                 if ($c->isPageDraft() && $this->permissions->canDeletePage()) {
                     $u = new User();
                     $cID = $u->getPreviousFrontendPageID();
                     $this->page->delete();
                     $pr->setRedirectURL(DIR_REL . '/' . DISPATCHER_FILENAME . '?cID=' . $cID);
                     $pr->outputJSON();
                 } else {
                     if ($v->canDiscard()) {
                         $v->discard();
                     }
                 }
             } else {
                 $v->removeNewStatus();
             }
         }
         $nc = Page::getByID($c->getCollectionID(), $v->getVersionID());
         $u->unloadCollectionEdit();
         $pr->setRedirectURL(Loader::helper('navigation')->getLinkToCollection($nc, true));
         $pr->outputJSON();
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:57,代码来源:check_in.php

示例3: renderHttpException

 /**
  * @param HttpException $e
  * @return Response
  */
 protected function renderHttpException(HttpException $e)
 {
     $status = $e->getStatusCode();
     $template = Config::get('http_exception_template');
     if (!\Norma\App::$debug && !empty($template[$status])) {
         return Response::create($template[$status], 'view', $status)->assign(['e' => $e]);
     } else {
         return $this->convertExceptionToResponse($e);
     }
 }
开发者ID:lunnlew,项目名称:Norma_Code,代码行数:14,代码来源:Handle.php

示例4: testCreateWithHttpErrorCode

 public function testCreateWithHttpErrorCode()
 {
     $code = 403;
     $rawResult = 'OK';
     $response = new Response();
     $response->create($code, $rawResult);
     $this->assertFalse($response->isOk());
     $this->assertEquals($rawResult, $response->getRawResult());
     $error = $response->getError();
     $this->assertEquals('HTTP_CODE_ERROR', $error);
 }
开发者ID:softhui,项目名称:AlibabaSDK,代码行数:11,代码来源:ResponseTest.php

示例5: register

 public function register($app)
 {
     /**
      * Error handler
      */
     $whoops = new \Whoops\Run();
     if (getenv('MODE') === 'dev') {
         $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
     } else {
         $whoops->pushHandler(function () {
             Response::create('Something broke', Response::HTTP_INTERNAL_SERVER_ERROR)->send();
         });
     }
     $whoops->register();
 }
开发者ID:alobintechnologies,项目名称:alophp,代码行数:15,代码来源:PrettyErrorServiceProvider.php

示例6: renderError

 /**
  * @param string $title
  * @param string $error
  * @param bool|\Exception $exception
  */
 public function renderError($title, $error, $exception = false)
 {
     $o = new stdClass();
     $o->title = $title;
     $o->content = $error;
     if ($exception) {
         $o->content .= $exception->getTraceAsString();
     }
     \Response::closeOutputBuffers(1, false);
     $ve = new ErrorView($o);
     \Response::create($ve->render($o))->send();
 }
开发者ID:ceko,项目名称:concrete5-1,代码行数:17,代码来源:UserInterface.php

示例7: function

            $input['comments'] = 0;
        }
        if (empty($input['html'])) {
            $input['status'] = 'draft';
        }
        $post = Post::create($input);
        Extend::process('post', $post->id);
        Notify::success(__('posts.created'));
        return Response::redirect('admin/posts');
    });
    /*
    	Preview post
    */
    Route::post('admin/posts/preview', function () {
        $html = Input::get('html');
        // apply markdown processing
        $md = new Markdown();
        $output = Json::encode(array('html' => $md->transform($html)));
        return Response::create($output, 200, array('content-type' => 'application/json'));
    });
    /*
    	Delete post
    */
    Route::get('admin/posts/delete/(:num)', function ($id) {
        Post::find($id)->delete();
        Comment::where('post', '=', $id)->delete();
        Query::table(Base::table('post_meta'))->where('post', '=', $id)->delete();
        Notify::success(__('posts.deleted'));
        return Response::redirect('admin/posts');
    });
});
开发者ID:pepfi,项目名称:anchor-cms,代码行数:31,代码来源:posts.php

示例8: Template

        return Response::create(new Template('404'), 404);
    }
    // search templating vars
    Registry::set('page', $page);
    Registry::set('page_offset', $offset);
    Registry::set('search_term', $term);
    Registry::set('search_results', new Items($posts));
    Registry::set('total_posts', $total);
    return new Template('search');
});
Route::post('search', function () {
    // search and save search ID
    $term = filter_var(Input::get('term', ''), FILTER_SANITIZE_STRING);
    // replace spaces with double-dash to pass through url
    $term = str_replace(' ', '--', $term);
    Session::put(slug($term), $term);
    return Response::redirect('search/' . slug($term));
});
/**
 * View pages
 */
Route::get('(:all)', function ($uri) {
    if (!($page = Page::slug($slug = basename($uri)))) {
        return Response::create(new Template('404'), 404);
    }
    if ($page->redirect) {
        return Response::redirect($page->redirect);
    }
    Registry::set('page', $page);
    return new Template('page');
});
开发者ID:gautamkrishnar,项目名称:Anchor-CMS-openshift-quickstart,代码行数:31,代码来源:site.php

示例9: exec

 /**
  * Execute the resource, that is, find the correct resource method to call
  * based upon the request and then call it.
  *
  * @return Tonic\Response
  */
 public function exec()
 {
     $this->setup();
     // get the annotation metadata for this resource
     $resourceMetadata = $this->app->getResourceMetadata($this);
     $methodPriorities = $this->calculateMethodPriorities($resourceMetadata);
     $methodName = null;
     $bestMatch = -2;
     foreach ($methodPriorities as $name => $priority) {
         if ($priority['value'] > $bestMatch) {
             $bestMatch = $priority['value'];
             $methodName = $name;
         }
     }
     if (!$methodName) {
         throw new Exception('No method matches request method');
     } elseif (isset($methodPriorities[$methodName]['response'])) {
         $response = Response::create($methodPriorities[$methodName]['response']);
     } elseif (isset($methodPriorities[$methodName]['exception'])) {
         throw $methodPriorities[$methodName]['exception'];
     } else {
         foreach (array('*', $methodName) as $mn) {
             if (isset($this->before[$mn])) {
                 foreach ($this->before[$mn] as $action) {
                     call_user_func($action, $this->request, $mn);
                 }
             }
         }
         $response = Response::create(call_user_func_array(array($this, $methodName), $this->params));
         foreach (array('*', $methodName) as $mn) {
             if (isset($this->after[$mn])) {
                 foreach ($this->after[$mn] as $action) {
                     call_user_func($action, $response, $mn);
                 }
             }
         }
     }
     return $response;
 }
开发者ID:LucasFrecia,项目名称:tonic,代码行数:45,代码来源:Resource.php

示例10: cache

 /**
  * 读取或者设置缓存
  * @access public
  * @param string $key 缓存标识,支持变量规则 ,例如 item/:name/:id
  * @param mixed  $expire 缓存有效期
  * @return mixed
  */
 public function cache($key, $expire = null)
 {
     if (false !== strpos($key, ':')) {
         $param = $this->param();
         foreach ($param as $item => $val) {
             if (is_string($val) && false !== strpos($key, ':' . $item)) {
                 $key = str_replace(':' . $item, $val, $key);
             }
         }
     }
     if (Cache::has($key)) {
         // 读取缓存
         $content = Cache::get($key);
         $response = Response::create($content)->code(304)->header('Content-Type', Cache::get($key . '_header'));
         throw new \think\exception\HttpResponseException($response);
     } else {
         $this->cache = array($key, $expire);
     }
 }
开发者ID:supefun,项目名称:SupeFramework,代码行数:26,代码来源:Request.php

示例11: rawSend

 /**
  * 原始发送请求
  * @param string $url 完整URL
  * @param string|array $bodyParam body请求体。$requestMethod为POST时有效
  * @param string $requestMethod 请求方法,必须全大写
  * @param Response $response
  * @return Response $response
  */
 public function rawSend($url, $bodyParam = null, $requestMethod = 'GET', Response $response = null)
 {
     if (null === $response) {
         $response = new Response();
     }
     if (null === $this->curlInit) {
         $this->curlInit = curl_init();
     }
     $curlOpt = $this->getDefaultCurlOpt();
     $curlOpt[CURLOPT_URL] = $url;
     if ($requestMethod == 'POST') {
         $curlOpt[CURLOPT_POST] = true;
     }
     $curlOpt[CURLOPT_CUSTOMREQUEST] = $requestMethod;
     if ($requestMethod == 'POST' || $requestMethod == 'PUT') {
         if (is_array($bodyParam)) {
             if (!$this->rawSendCheckHasFile($bodyParam)) {
                 $bodyParam = http_build_query($bodyParam);
             } else {
                 $bodyParam = $this->rawSendBuildCleanUploadBody($bodyParam);
             }
         }
         if ($bodyParam !== null && $bodyParam !== "") {
             $curlOpt[CURLOPT_POSTFIELDS] = $bodyParam;
         } else {
             $curlOpt[CURLOPT_POSTFIELDS] = "";
         }
     }
     curl_setopt_array($this->curlInit, $curlOpt);
     $rawResult = curl_exec($this->curlInit);
     $curlInfo = curl_getinfo($this->curlInit);
     $curl_errno = curl_errno($this->curlInit);
     if ($curl_errno) {
         $response->setError("CURL_ERROR", curl_error($this->curlInit) . '[ErrCode ' . $curl_errno . ']');
     } else {
         $response->create($curlInfo['http_code'], $rawResult);
     }
     $response->setExtractInfo($curlInfo);
     if (!empty($this->requestLoggerStack)) {
         $this->dispatchRequestLogger($url, isset($curlOpt[CURLOPT_POSTFIELDS]) ? $curlOpt[CURLOPT_POSTFIELDS] : null, $requestMethod, $response);
     }
     return $response;
 }
开发者ID:HorseLuke,项目名称:QcloudApi-SDK-PHP,代码行数:51,代码来源:Request.php

示例12: isset

 */
include "./admin/include/common.php";
$r_id = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : 0;
$exists = Ad::exists($r_id, array("active" => 1));
if ($exists) {
    $ad = Ad::get_one($r_id);
    if (isset($_POST['send']) && User::is_logged_in()) {
        $success = true;
        $errors = array();
        $p_message = strip_tags($_POST['message']);
        if ($p_message == '') {
            $success = false;
            array_push($errors, "Please enter your message.");
        }
        if ($p_message != '' && !preg_match('/^[\\s\\S]{0,500}$/u', $p_message)) {
            $success = false;
            array_push($errors, "The message must be no more than 500 character long.");
        }
        if ($success) {
            $userid = USER::get_id();
            $username = USER::get_name();
            $adid = $r_id;
            $response = $p_message;
            Response::create(array('ad_id' => $adid, 'user_id' => $userid, 'message' => $response));
            $content = StaticContent::get_content('ad-response-email');
            eval("\$content = \"{$content}\";");
            mail($ad['email'], 'Response to your ad', $content, "From: " . $noreply);
        }
    }
}
include "./templates/ad-respond.php";
开发者ID:noverkill,项目名称:classified-ads-script,代码行数:31,代码来源:ad-respond.php

示例13: addResponse

 function addResponse($vars, &$errors)
 {
     $vars['ticketId'] = $this->getTicketId();
     $vars['userId'] = 0;
     return Response::create($vars, $errors);
 }
开发者ID:CarlosAvilesMx,项目名称:CarlosAviles.Mx,代码行数:6,代码来源:class.thread.php

示例14: addResponse

 function addResponse($vars, &$errors)
 {
     $vars['ticketId'] = $this->getTicketId();
     // DELME: When HTML / rich-text is supported
     $vars['title'] = Format::htmlchars($vars['title']);
     $vars['response'] = Format::htmlchars($vars['response']);
     return Response::create($vars, $errors);
 }
开发者ID:pkdevboxy,项目名称:osTicket-1.7,代码行数:8,代码来源:class.thread.php

示例15: parse_str

    case 'GET':
        $request->parameters = $_GET;
        break;
    case 'POST':
        $request->parameters = $_POST;
        break;
    case 'PUT':
        parse_str(file_get_contents('php://input'), $request->parameters);
        break;
}
/**
 * Route the request.
 */
if (!empty($request->url_elements)) {
    $controller_name = ucfirst($request->url_elements[0]) . 'Controller';
    if (class_exists($controller_name)) {
        $controller = new $controller_name();
        $action_name = strtolower($request->method);
        $response_str = call_user_func_array(array($controller, $action_name), array($request));
    } else {
        header('HTTP/1.1 404 Not Found');
        $response_str = 'Unknown request: ' . $request->url_elements[0];
    }
} else {
    $response_str = 'Unknown request';
}
/**
 * Send the response to the client.
 */
$response_obj = Response::create($response_str, $_SERVER['HTTP_ACCEPT']);
echo $response_obj->render();
开发者ID:Roeebh,项目名称:api-framework,代码行数:31,代码来源:index.php


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