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


PHP Response::setStatus方法代码示例

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


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

示例1: testSetStatus

 function testSetStatus()
 {
     $response = new Response();
     $response->setStatus('402 Where\'s my money?');
     $this->assertEquals(402, $response->getStatus());
     $this->assertEquals('Where\'s my money?', $response->getStatusText());
 }
开发者ID:sebbie42,项目名称:casebox,代码行数:7,代码来源:ResponseTest.php

示例2: serve

 public function serve($app)
 {
     if (!is_callable($app)) {
         throw new InvalidArgumentException('not a valid app');
     }
     $this->log('Serving ' . (is_object($app) ? get_class($app) : $app) . ' app…');
     try {
         $this->log("got request");
         $context = array('env' => $_SERVER, 'stdin' => fopen("php://input", "r"), 'logger' => function ($message) {
             trigger_error($message, E_USER_NOTICE);
         }, '_GET' => $_GET, '_POST' => $_POST, '_FILES' => $_FILES, '_COOKIE' => new Cookies());
         $result = call_user_func($app, $context);
         $response = new Response();
         $response->setStatus($result[0]);
         for ($i = 0, $cnt = count($result[1]); $i < $cnt; $i++) {
             $response->addHeader($result[1][$i], $result[1][++$i]);
         }
         unset($response);
         echo $result[2];
         unset($result);
         $this->log("-> done with request");
     } catch (\Exception $e) {
         $this->log('[Exception] ' . get_class($e) . ': ' . $e->getMessage());
     }
 }
开发者ID:bermi,项目名称:akelos,代码行数:25,代码来源:Handler.class.php

示例3: saveuser

 function saveuser()
 {
     $response = new Response();
     try {
         $id = $this->input->post("user-id");
         $email = $this->input->post("email");
         $firstName = $this->input->post("first-name");
         $lastName = $this->input->post("last-name");
         $role = $this->input->post("role");
         $subDivision = $this->input->post("sub-division");
         $user = new User();
         if ($id != null && $id != "") {
             $user = $this->findById("User", $id);
         }
         $user->setEmail($email);
         $user->setUsername($email);
         $user->setPassword("");
         $user->setFirstName($firstName);
         $user->setLastName($lastName);
         $subDivision = $this->findById("Subdivision", $subDivision);
         $user->setSubdivision($subDivision);
         $role = $this->getRoleByName($role);
         $user->setRole($role[0]);
         $token = $this->getRandomCode();
         $user->setToken($token);
         $this->save($user);
         $emailMessage = "Hi " . $user->getName() . ", <br/> Your account has been activate on " . base_url() . ". Please <a href='" . site_url() . "/validate/" . $token . "'>click here </a> to create you password.";
         $this->sendMail($user->getEmail(), "Active you account.", $emailMessage);
     } catch (Exception $e) {
         $response->setStatus(false);
         $response->setErrorMessage($e->getMessage());
     }
     $this->output->set_content_type('application/json')->set_output(json_encode($response));
 }
开发者ID:digvijaymohite,项目名称:e-tender,代码行数:34,代码来源:Users.php

示例4: jsonDeserialize

 public static function jsonDeserialize($content)
 {
     $data = json_decode($content);
     $keys = array_keys(json_decode($content, true));
     $response = new Response();
     foreach ($keys as $key) {
         switch ($key) {
             case 'status':
                 $response->setStatus($data->status);
                 break;
             case 'data':
                 $response->setData($data->data);
                 break;
             case 'error':
                 $response->setErrorMessage($data->error);
                 break;
             case 'code':
                 $response->setErrorCode($data->code);
                 break;
             case 'metadata':
                 foreach ((array) $data->metadata as $key => $value) {
                     $response->setMetadata($key, $value);
                 }
                 break;
         }
     }
     return $response;
 }
开发者ID:chriscalifornia88,项目名称:min,代码行数:28,代码来源:Response.php

示例5: sendForBilling

 function sendForBilling()
 {
     $response = new Response();
     try {
         $projectId = $this->input->post("project-id");
         $amount = $this->input->post("project-bill-amount");
         $billDoc = $this->input->post("bill-doc");
         $project = $this->findById("Project", $projectId);
         if ($project == null) {
             throw new RuntimeException("Invalid Project..!");
         }
         $project->setStatus(Project::PROJECT_BILL);
         $project->getWorkOrder()->setStatus(Workorder::STATUS_COMPLETED);
         $project->getWorkOrder()->setApprovedBy($this->getLoggedInUser());
         $bill = new Bill();
         $bill->setAmount($amount);
         $bill->setProject($project);
         $bill->setCreated(new DateTime());
         $bill->setStatus(Bill::STATUS_PENDING);
         if ($billDoc != null && $billDoc != "") {
             foreach ($billDoc as $file) {
                 $doc = new Document();
                 $doc->setName($file);
                 $doc->setCreated(new DateTime());
                 $bill->getBillDoc()->add($doc);
             }
         }
         $this->save($bill);
         $response->setData(Project::PROJECT_BILL);
     } catch (Exception $e) {
         $response->setStatus(false);
         $response->setErrorMessage($e->getMessage());
     }
     $this->output->set_content_type('application/json')->set_output(json_encode($response));
 }
开发者ID:digvijaymohite,项目名称:e-tender,代码行数:35,代码来源:Workorders.php

示例6: __construct

 /**
  * @param string $message Message.
  * @param int $code Error code.
  * @param mixed $customMessages Additional information about error.
  *
  * @todo определиться с $customMessages: это mixed или array?
  */
 public function __construct($message, $code = self::ERR_CRITICAL, $customMessages = null)
 {
     $this->response = E()->getResponse();
     if (isset($customMessages)) {
         if (!is_array($customMessages)) {
             $this->customMessages = array($customMessages);
         } else {
             $this->customMessages = $customMessages;
         }
     }
     if ($code == self::ERR_LANG) {
         $this->response->setStatus(503);
         $this->response->setHeader('Retry-After', 20);
         $message = translate($message, E()->getLanguage()->getDefault());
     } elseif ($code == self::ERR_403) {
         $this->response->setStatus(403);
         $message = translate($message, E()->getLanguage()->getCurrent());
     } elseif ($code == self::ERR_404) {
         $this->response->setStatus(404);
         $message = translate($message, E()->getLanguage()->getCurrent());
     } elseif ($code != self::ERR_DB) {
         $message = translate($message, E()->getLanguage()->getCurrent());
     }
     $this->backtrace = debug_backtrace(!DEBUG_BACKTRACE_PROVIDE_OBJECT, 5);
     parent::__construct($message, $code);
 }
开发者ID:energine-cmf,项目名称:energine,代码行数:33,代码来源:SystemException.php

示例7: approve

 function approve()
 {
     $response = new Response();
     try {
         $projectId = $this->input->post("project-id");
         $amount = floatval($this->input->post("project-bill-amount"));
         $project = $this->findById("Project", $projectId);
         if ($projectId == null) {
             throw new RuntimeException("Invalid Request");
         }
         $availableAmount = $this->getAvailableFundAmountByScheme($project->getScheme()->getId());
         if ($amount > floatval($availableAmount)) {
             throw new RuntimeException("Insufficient Funds !");
         }
         $utilisedAmt = 0;
         foreach ($this->getAvailableFunds($project->getScheme()) as $fund) {
             /*if($fund->getAmount() == $fund->getUsedAmount()){
                   continue;
               }*/
             $reqAmt = $amount - $utilisedAmt;
             $fundDetails = new FundDetails();
             $fundDetails->setCreated(new DateTime());
             $availableAmount = $fund->getAmount() - $fund->getUsedAmount();
             if ($availableAmount >= $reqAmt) {
                 $fundDetails->setAmount($reqAmt);
                 $fund->setUsedAmount($fund->getUsedAmount() + $reqAmt);
                 $utilisedAmt = $amount;
             } else {
                 if ($reqAmt <= $availableAmount) {
                     $fund->setUsedAmount($fund->getUsedAmount() + $reqAmt);
                     $fundDetails->setAmount($reqAmt);
                     $utilisedAmt = $utilisedAmt + $reqAmt;
                 } else {
                     $fund->setUsedAmount($fund->getUsedAmount() + $availableAmount);
                     $fundDetails->setAmount($availableAmount);
                     $utilisedAmt = $utilisedAmt + $availableAmount;
                 }
             }
             $fundDetails->setFund($fund);
             $fundDetails->setProject($project);
             $project->getFundDetails()->add($fundDetails);
             if ($utilisedAmt == $amount) {
                 break;
             }
         }
         $bill = $project->getBill();
         $bill->setApprovedBy($this->getLoggedInUser());
         $bill->setApprovedAmount($amount);
         $bill->setStatus(Bill::STATUS_APPROVED);
         $project->setStatus(Project::PROJECT_COMPLETED);
         $this->save($project);
         $response->setData(Bill::STATUS_APPROVED);
     } catch (Exception $e) {
         $response->setStatus(false);
         $response->setErrorMessage($e->getMessage());
     }
     $this->output->set_content_type('application/json')->set_output(json_encode($response));
 }
开发者ID:digvijaymohite,项目名称:e-tender,代码行数:58,代码来源:Bills.php

示例8: respond

 /**
  * Sets the response body and status code header
  *
  * @param mixed $data
  * @param integer $status
  * @return void
  */
 protected function respond($data, $status = null)
 {
     if ($this->performedRespond) {
         throw new DoubleRespond();
     }
     $this->response->setStatus(!empty($status) ? $status : $this->status);
     $this->response->setBody($data);
     $this->performedRespond = true;
 }
开发者ID:vincenta,项目名称:stato,代码行数:16,代码来源:Controller.php

示例9: writeResponse

 public function writeResponse($response_data)
 {
     $response = new Response($this);
     $response->setStatus($response_data[0]);
     for ($i = 0, $cnt = count($response_data[1]); $i < $cnt; $i++) {
         $response->addHeader($response_data[1][$i], $response_data[1][++$i]);
     }
     $response->sendHeaders();
     $this->write($response_data[2]);
     // body
 }
开发者ID:bermi,项目名称:akelos,代码行数:11,代码来源:Server.class.php

示例10: actionGet

 /**
  * Returns a list of users.
  * @return void
  */
 public function actionGet()
 {
     $response = new Response();
     $users = User::model()->findAll();
     $data = array();
     foreach ($users as $user) {
         $data[] = $user->getResponseData();
     }
     $response->setStatus(Response::STATUS_OK);
     $response->setData('list', $data);
     $response->setData('total', count($users));
     echo $response;
 }
开发者ID:rBoost,项目名称:WRUD,代码行数:17,代码来源:UserController.php

示例11: writeResponse

 public function writeResponse($response_data)
 {
     $response = new Response($this);
     $response->setStatus($response_data[0]);
     for ($i = 0, $cnt = count($response_data[1]); $i < $cnt; $i++) {
         $response->addHeader($response_data[1][$i], $response_data[1][++$i]);
     }
     $response->sendHeaders();
     if (!is_resource($response_data[2])) {
         $this->write($response_data[2]);
     } else {
         while (!feof($response_data[2])) {
             $this->write(fread($response_data[2], 1024));
         }
     }
 }
开发者ID:umonkey,项目名称:appserver-in-php,代码行数:16,代码来源:Server.class.php

示例12: doExecute

 private function doExecute($curlHandle, Request $request)
 {
     curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
     curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curlHandle, CURLOPT_HEADER, true);
     curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array('Accept: ' . $request->getHttpAccept()));
     $res = curl_exec($curlHandle);
     $info = curl_getinfo($curlHandle);
     $response = new Response();
     $response->setStatus($info['http_code']);
     if (false !== $res) {
         $response->setHeaders(substr($res, 0, $info['header_size']));
         $response->setBody(substr($res, -$info['download_content_length']));
     }
     return $response;
 }
开发者ID:karamani,项目名称:beresta,代码行数:16,代码来源:RestClient.php

示例13: testMarshalling

 public function testMarshalling()
 {
     $response = new Response();
     $response->setStatus(array('Code' => 'OurStatusCode', 'SubCode' => 'OurSubStatusCode', 'Message' => 'OurMessageText'));
     $responseElement = $response->toUnsignedXML();
     $statusElements = Utils::xpQuery($responseElement, './saml_protocol:Status');
     $this->assertCount(1, $statusElements);
     $statusCodeElements = Utils::xpQuery($statusElements[0], './saml_protocol:StatusCode');
     $this->assertCount(1, $statusCodeElements);
     $this->assertEquals('OurStatusCode', $statusCodeElements[0]->getAttribute("Value"));
     $nestedStatusCodeElements = Utils::xpQuery($statusCodeElements[0], './saml_protocol:StatusCode');
     $this->assertCount(1, $nestedStatusCodeElements);
     $this->assertEquals('OurSubStatusCode', $nestedStatusCodeElements[0]->getAttribute("Value"));
     $statusMessageElements = Utils::xpQuery($statusElements[0], './saml_protocol:StatusMessage');
     $this->assertCount(1, $statusMessageElements);
     $this->assertEquals('OurMessageText', $statusMessageElements[0]->textContent);
 }
开发者ID:SysBind,项目名称:saml2,代码行数:17,代码来源:StatusResponseTest.php

示例14: dispatch

 /**
  * Dispatch the given request by finding and invoking the handler matching the request data.
  *
  * @param Request $request 
  * @param Response $response 
  * @return Response
  */
 public function dispatch(Request $request, Response $response)
 {
     $matches = $this->match($request->getPath(), $request->getMethod());
     if ($matches === null) {
         throw new \Exception('No routes match the path ' . $request->getPath() . '');
     }
     if (!is_callable($matches['handler'])) {
         throw new \Exception('The given handler is not a valid callback.');
     }
     $result = call_user_func_array($matches['handler'], array_merge(array($this->application), $matches['params']));
     if (is_string($result)) {
         $response->setContent($result);
     } elseif (is_numeric($result)) {
         $response->setStatus($result);
     }
     return $response;
 }
开发者ID:niceboy120,项目名称:verbier,代码行数:24,代码来源:Dispatcher.php

示例15: deleteAction

 public function deleteAction()
 {
     $params = Request::getParams();
     $validator = new Validator();
     $params = $validator->sanitize($params);
     $validator->validation_rules(array("id" => "required|numeric|checkIfRecordIdExists"));
     $validated_data = $validator->run($params);
     if ($validated_data === false) {
         Response::setStatus(404);
         $returnArray = array("error" => "Invalid data was sent", "messages" => $validator->get_readable_errors());
     } else {
         $model = new Model_Record();
         $model->delete($params['id']);
         Response::setStatus(204);
         $returnArray = array();
     }
     return $returnArray;
 }
开发者ID:blindly,项目名称:ginger-pdns-api,代码行数:18,代码来源:Record.php


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