• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Response类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get

 function get($request, $user)
 {
     $response = new Response($request);
     $response->code = Response::OK;
     $response->addHeader('content-type', 'text/plain');
     $data = array();
     ouverture();
     // recherche du championnat en cours
     $querySaisonEnCours = "SELECT phpl_gr_championnats.id\r\n\t\t\t\t\t\t\t\tFROM phpl_gr_championnats \r\n\t\t\t\t\t\t\t\tWHERE phpl_gr_championnats.activ_prono = '1' \r\n\t\t\t\t\t\t\t\tORDER by id desc";
     $resultat = mysql_query($querySaisonEnCours) or die("probleme " . mysql_error());
     $row = mysql_fetch_array($resultat);
     $idSaisonEnCours = $row[0];
     // recherche de l'id de la dernière journée
     $queryDerniereJournee = "SELECT max(evolutionGraph.fin)\r\n\t\t\t\t\t\t\t\tFROM phpl_pronos_graph evolutionGraph\r\n\t\t\t\t\t\t\t\tWHERE evolutionGraph.id_gr_champ = '{$idSaisonEnCours}'";
     $resultat = mysql_query($queryDerniereJournee);
     $row = mysql_fetch_array($resultat);
     $idDerniereJournee = $row[0];
     // évolution sur la dernière journée
     $queryEvolution = "SELECT P2.type, P2.classement as place, (P2.points - P1.points) as points, (P1.classement - P2.classement) as evolution\r\n    \t\t\t\t\t\t FROM phpl_membres membre\r\n\t\t\t\t             JOIN phpl_pronos_graph P1 ON P1.id_membre = membre.id_prono\r\n\t\t\t\t             \t\t\t\t\t\t  AND P1.id_gr_champ = '{$idSaisonEnCours}'\r\n\t\t\t\t             \t\t\t\t\t\t  AND P1.type in ('general', 'hourra', 'mixte')\r\n\t\t\t\t\t\t\t   \t\t\t\t\t\t  AND P1.fin = '" . ($idDerniereJournee - 1) . "'\t\t             \t\t\t\t\t\t  \r\n\t\t\t\t             JOIN phpl_pronos_graph P2 ON P2.id_membre = P1.id_membre\r\n\t\t\t\t             \t\t\t\t\t\t  AND P2.id_gr_champ = P1.id_gr_champ\r\n\t\t\t\t             \t\t\t\t\t\t  AND P2.type = P1.type\r\n\t\t\t\t               \t\t\t\t\t\t  AND P2.fin = '{$idDerniereJournee}'\r\n\t\t\t\t             WHERE pseudo = '{$user}'\t\t             \t\t\t\t\t\t  \t             \r\n\t\t\t\t\t\t\t ORDER BY P2.type";
     $resultat = mysql_query($queryEvolution) or die("probleme " . mysql_error());
     while ($row = mysql_fetch_array($resultat)) {
         $typeChamp = $row["type"];
         $numPlace = $row['place'];
         $nbPoints = $row['points'];
         $numEvolution = $row["evolution"];
         array_push($data, array("type" => $typeChamp, "place" => $numPlace, "points" => $nbPoints, "evolution" => $numEvolution));
     }
     // Retour du tableau au format JSON
     $response->body = json_encode(array("profilStat" => $data));
     return $response;
 }
开发者ID:pronoschallenge,项目名称:PronosChallenge,代码行数:31,代码来源:profilStat.php


示例2: testGetReasonPhraseReturnsTheReasonPhrase

 public function testGetReasonPhraseReturnsTheReasonPhrase()
 {
     $response = new Response();
     $this->assertEquals($response->getReasonPhrase(), null);
     $response->addHeader('1.0 200 OK');
     $this->assertEquals($response->getReasonPhrase(), 'OK');
 }
开发者ID:philip,项目名称:Buzz,代码行数:7,代码来源:ResponseTest.php


示例3: set_cache

 /**
  * Override of the set_cache method, works in exactly the same way except
  * the check for the max-age header in the response has been removed so that
  * Codebase API responses will always be cached, this breaks HTTP Cache
  * rules but is the cleanest way of enabling caching for all responses
  * within Kohana.
  *
  * @param	Response	$response
  * @return	boolean
  */
 public function set_cache(Response $response)
 {
     $headers = $response->headers()->getArrayCopy();
     if ($cache_control = Arr::get($headers, 'cache-control')) {
         // Parse the cache control
         $cache_control = HTTP_Header::parse_cache_control($cache_control);
         // If the no-cache or no-store directive is set, return
         if (array_intersect($cache_control, array('no-cache', 'no-store'))) {
             return FALSE;
         }
         // Check for private cache and get out of here if invalid
         if (!$this->_allow_private_cache and in_array('private', $cache_control)) {
             if (!isset($cache_control['s-maxage'])) {
                 return FALSE;
             }
             // If there is a s-maxage directive we can use that
             $cache_control['max-age'] = $cache_control['s-maxage'];
         }
     }
     /**
      * if the max-age cache control header is set to 0 in the response, set
      * it to 1 hour so the reponse will be cacheable
      */
     $cache_control_header = $response->headers('Cache-Control');
     $response->headers('Cache-Control', str_replace('max-age=0', 'max-age=3600', $cache_control_header));
     if ($expires = Arr::get($headers, 'expires') and !isset($cache_control['max-age'])) {
         // Can't cache things that have expired already
         if (strtotime($expires) <= time()) {
             return FALSE;
         }
     }
     return TRUE;
 }
开发者ID:rpa-design,项目名称:codebase,代码行数:43,代码来源:cache.php


示例4: 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


示例5: testIfRedirectReturnsCorrectHttpCodeAndLocationHeader

 /**
  * @test
  * @param $url
  * @param $statusCode
  * @dataProvider redirectDataProvider
  */
 public function testIfRedirectReturnsCorrectHttpCodeAndLocationHeader($url, $statusCode)
 {
     $response = new Response();
     $response->redirect($url, $statusCode);
     $this->assertEquals($url, $response->headers->get('Location'));
     $this->assertEquals($statusCode, $response->getStatusCode());
 }
开发者ID:lcobucci,项目名称:action-mapper,代码行数:13,代码来源:ResponseTest.php


示例6: initcall

function initcall()
{
    if ($_REQUEST["CallStatus"] == "completed") {
        // receives request from Twilio server when a call ends
        // remove call from active calls
        // saves call info in DB as current call
        $callGuid = $_REQUEST["CallGuid"];
        $db = new PDO("sqlite:twilio.db");
        $query = "UPDATE Calls SET Status = 'ended' WHERE CallGuid = '{$callGuid}'";
        $db->exec($query);
    } else {
        // dial all saved numbers for your account
        $numbers = getNumbersToCall();
        // get numbers
        $r = new Response();
        for ($i = 0; $i < count($numbers); $i++) {
            $r->addDial($numbers[$i]);
        }
        $r->Respond();
        // saves call info in DB as current call
        $callGuid = $_REQUEST["CallGuid"];
        $caller = $_REQUEST["Caller"];
        $callLocation = $_REQUEST["CallerCity"] != "" ? $_REQUEST["CallerCity"] : ($_REQUEST["CallerState"] != "" ? $_REQUEST["CallerState"] : ($_REQUEST["CallerZip"] != "" ? $_REQUEST["CallerZip"] : ($_REQUEST["CallerCountry"] != "" ? $_REQUEST["CallerCountry"] : "")));
        $db = new PDO("sqlite:twilio.db");
        $query = "INSERT INTO Calls (CallGuid, Caller, Location, Status) VALUES ('{$callGuid}', '{$caller}', '{$callLocation}', 'active')";
        $db->exec($query);
    }
}
开发者ID:Timothee,项目名称:Notwilfications,代码行数:28,代码来源:index.php


示例7: _send_message

 /**
  * Sends the HTTP message [Request] to a remote server and processes
  * the response.
  *
  * @param   Request   $request  request to send
  * @param   Response  $request  response to send
  * @return  Response
  */
 public function _send_message(Request $request, Response $response)
 {
     // Response headers
     $response_headers = array();
     $options = array();
     // Set the request method
     $options = $this->_set_curl_request_method($request, $options);
     // Set the request body. This is perfectly legal in CURL even
     // if using a request other than POST. PUT does support this method
     // and DOES NOT require writing data to disk before putting it, if
     // reading the PHP docs you may have got that impression. SdF
     // This will also add a Content-Type: application/x-www-form-urlencoded header unless you override it
     if ($body = $request->body()) {
         $options[CURLOPT_POSTFIELDS] = $request->body();
     }
     // Process headers
     if ($headers = $request->headers()) {
         $http_headers = array();
         foreach ($headers as $key => $value) {
             $http_headers[] = $key . ': ' . $value;
         }
         $options[CURLOPT_HTTPHEADER] = $http_headers;
     }
     // Process cookies
     if ($cookies = $request->cookie()) {
         $options[CURLOPT_COOKIE] = http_build_query($cookies, NULL, '; ');
     }
     // Get any exisiting response headers
     $response_header = $response->headers();
     // Implement the standard parsing parameters
     $options[CURLOPT_HEADERFUNCTION] = array($response_header, 'parse_header_string');
     $this->_options[CURLOPT_RETURNTRANSFER] = TRUE;
     $this->_options[CURLOPT_HEADER] = FALSE;
     // Apply any additional options set to
     $options += $this->_options;
     $uri = $request->uri();
     if ($query = $request->query()) {
         $uri .= '?' . http_build_query($query, NULL, '&');
     }
     // Open a new remote connection
     $curl = curl_init($uri);
     // Set connection options
     if (!curl_setopt_array($curl, $options)) {
         throw new Request_Exception('Failed to set CURL options, check CURL documentation: :url', array(':url' => 'http://php.net/curl_setopt_array'));
     }
     // Get the response body
     $body = curl_exec($curl);
     // Get the response information
     $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     if ($body === FALSE) {
         $error = curl_error($curl);
     }
     // Close the connection
     curl_close($curl);
     if (isset($error)) {
         throw new Request_Exception('Error fetching remote :url [ status :code ] :error', array(':url' => $request->url(), ':code' => $code, ':error' => $error));
     }
     $response->status($code)->body($body);
     return $response;
 }
开发者ID:creat2012,项目名称:hustoj_official,代码行数:68,代码来源:Curl.php


示例8: testShouldReturnFalseWhenCallForEmptyResponseIfIsOk

 public function testShouldReturnFalseWhenCallForEmptyResponseIfIsOk()
 {
     // Set
     $response = new Response();
     // Assert
     $this->assertFalse($response->isOk());
 }
开发者ID:leroy-merlin-br,项目名称:laravel-axado-api,代码行数:7,代码来源:ResponseTest.php


示例9: _main

 /**
  * Get the latest raffle
  * 
  * @param Request
  * @return Response
  * */
 public function _main(Request $request)
 {
     // set Spanish so the date come in Spanish
     setlocale(LC_TIME, "es_ES");
     // get the current raffle
     $raffle = $this->utils->getCurrentRaffle();
     // show message if there is no open raffle
     if (!$raffle) {
         $response = new Response();
         $response->subject = "No hay ninguna Rifa abierta";
         $response->createFromText("Lo sentimos, no hay ninguna Rifa abierta ahora mismo. Pruebe nuevamente en algunos d&iacute;as.");
         return $response;
     }
     // get number of tickets adquired by the user
     $connection = new Connection();
     $userTickets = $connection->deepQuery("SELECT count(*) as tickets FROM ticket WHERE raffle_id is NULL AND email = '{$request->email}'");
     $userTickets = $userTickets[0]->tickets;
     // link to connect cuba logo
     $connectCubaLogo = "{$this->pathToService}/images/connectcuba.jpg";
     // create a json object to send to the template
     $responseContent = array("description" => $raffle->item_desc, "startDate" => $raffle->start_date, "endDate" => $raffle->end_date, "tickets" => $raffle->tickets, "image" => $raffle->image, "userTickets" => $userTickets, "connectCubaLogo" => $connectCubaLogo);
     // create the final user Response
     $response = new Response();
     $response->subject = "La Rifa de Apretaste";
     $response->createFromTemplate("basic.tpl", $responseContent, array($raffle->image, $connectCubaLogo));
     return $response;
 }
开发者ID:Apretaste,项目名称:rifa,代码行数:33,代码来源:service.php


示例10: __invoke

 /**
  * @param Request  $req
  * @param Response $res
  *
  * @return Response
  */
 public function __invoke($req, $res)
 {
     if ($req->isHtml()) {
         $res->render(new View('not_found', ['title' => 'Not Found']));
     }
     return $res->setCode(404);
 }
开发者ID:idealistsoft,项目名称:framework-bootstrap,代码行数:13,代码来源:NotFoundHandler.php


示例11: store

 /**
  * Store the cookies from a response.
  *
  * Store the cookies that haven't expired. If a cookie has been expired
  * and is currently stored, it will be removed.
  *
  * @param \Cake\Http\Client\Response $response The response to read cookies from
  * @param string $url The request URL used for default host/path values.
  * @return void
  */
 public function store(Response $response, $url)
 {
     $host = parse_url($url, PHP_URL_HOST);
     $path = parse_url($url, PHP_URL_PATH);
     $path = $path ?: '/';
     $cookies = $response->cookies();
     foreach ($cookies as $name => $cookie) {
         if (empty($cookie['domain'])) {
             $cookie['domain'] = $host;
         }
         if (empty($cookie['path'])) {
             $cookie['path'] = $path;
         }
         $key = implode(';', [$cookie['name'], $cookie['domain'], $cookie['path']]);
         $expires = isset($cookie['expires']) ? $cookie['expires'] : false;
         $expiresTime = false;
         if ($expires) {
             $expiresTime = strtotime($expires);
         }
         if ($expiresTime && $expiresTime <= time()) {
             unset($this->_cookies[$key]);
             continue;
         }
         $this->_cookies[$key] = $cookie;
     }
 }
开发者ID:nrother,项目名称:cakephp,代码行数:36,代码来源:CookieCollection.php


示例12: post

 function post($request)
 {
     $response = new Response($request);
     if (isset($_POST['tour'])) {
         // Remove those slashes
         if (get_magic_quotes_gpc()) {
             $tour = stripslashes($_POST['tour']);
         } else {
             $tour = $_POST['tour'];
         }
         $tour_obj = json_decode($tour);
         $entitymanager = GeocacheManager::getInstance();
         //~ print_r($tour_obj);
         $data = array();
         $data['name'] = $tour_obj->name;
         $data['webcode'] = isset($tour_obj->webcode) ? $tour_obj->webcode : $this->get_new_webcode();
         $data['geocaches'] = $entitymanager->parseGeocaches($tour_obj->geocaches);
         $data['ownWaypoints'] = $entitymanager->parseOwnWaypoints($tour_obj->costumMarkers);
         $tour = new Tour($data);
         $tour->save();
         $response->code = Response::OK;
         $response->addHeader('Content-type', 'text/plain');
         $response->body = $tour->__toJSON();
     } else {
         $response->code = Response::BADREQUEST;
     }
     return $response;
 }
开发者ID:ThomDietrich,项目名称:gctour,代码行数:28,代码来源:tour_save.php


示例13: respond

 public function respond(Response $response)
 {
     $fullClassName = $this->pageClass->getFullyQualifiedName();
     $page = new $fullClassName();
     $page->renderPage();
     $response->flush();
 }
开发者ID:picon,项目名称:picon-framework,代码行数:7,代码来源:PageRequestTarget.php


示例14: handle

 public static function handle(Exception $e)
 {
     switch (get_class($e)) {
         case 'HTTP_Exception_404':
             $response = new Response();
             $response->status(404);
             $view = new View('errors/error404');
             Controller_Abstract::add_static();
             if (Kohana::$environment == Kohana::DEVELOPMENT) {
                 $view->message = $e->getMessage();
             }
             echo $response->body($view)->send_headers()->body();
             return TRUE;
             break;
         case 'HTTP_Exception_410':
             $response = new Response();
             $response->status(410);
             $view = new View('errors/error410');
             Controller_Abstract::add_static();
             echo $response->body($view)->send_headers()->body();
             return TRUE;
             break;
         default:
             header('C-Data: ' . uniqid() . str_replace('=', '', base64_encode($e->getMessage())));
             return Kohana_Exception::handler($e);
             break;
     }
 }
开发者ID:nergal,项目名称:2mio,代码行数:28,代码来源:handler.php


示例15: preview_page

 public function preview_page()
 {
     $page = Page::getByID(intval($_REQUEST['cID'], 10), 'RECENT');
     if (!is_object($page) || $page->isError()) {
         throw new \InvalidArgumentException('Invalid collection ID');
     }
     $permissions = new Permissions($page);
     if ($permissions->canPreviewPageAsUser() && $permissions->canRead() && Config::get('concrete.permissions.model') == 'advanced') {
         /** @var Request $request */
         $request = Request::getInstance();
         $request->setCustomRequestUser(false);
         $request->setCurrentPage($page);
         if ($request->request('customUser')) {
             $user_info = UserInfo::getByUserName($request->request('customUser'));
             if ($user_info && is_object($user_info) && !$user_info->isError()) {
                 $request->setCustomRequestUser($user_info);
             }
         }
         $request->setCustomRequestDateTime(Core::make('helper/form/date_time')->translate('preview_as_user_datetime', $request->request()));
         $controller = $page->getPageController();
         $view = $controller->getViewObject();
         $response = new \Response();
         $response->setContent($view->render());
         $response->send();
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:26,代码来源:preview_as_user.php


示例16: mainAction

 public function mainAction()
 {
     // inicialize supporting classes
     $connection = new Connection();
     $email = new Email();
     $service = new Service();
     $service->showAds = false;
     $render = new Render();
     $response = new Response();
     $utils = new Utils();
     $wwwroot = $this->di->get('path')['root'];
     // get valid people
     $people = $connection->deepQuery("\n\t\t\tSELECT email, username, first_name, last_access\n\t\t\tFROM person\n\t\t\tWHERE active=1\n\t\t\tAND email not in (SELECT DISTINCT email FROM delivery_dropped)\n\t\t\tAND DATE(last_access) > DATE('2016-05-01')\n\t\t\tAND email like '%.cu'\n\t\t\tAND email not like '%@mms.cubacel.cu'");
     // send the remarketing
     $log = "";
     foreach ($people as $person) {
         // get the email address
         $newEmail = "apretaste+{$person->username}@gmail.com";
         // create the variabels to pass to the template
         $content = array("newemail" => $newEmail, "name" => $person->first_name);
         // create html response
         $response->setEmailLayout("email_simple.tpl");
         $response->createFromTemplate('newEmail.tpl', $content);
         $response->internal = true;
         $html = $render->renderHTML($service, $response);
         // send the email
         $email->sendEmail($person->email, "Sorteando las dificultades, un email lleno de alegria", $html);
         $log .= $person->email . "\n";
     }
     // saving the log
     $logger = new \Phalcon\Logger\Adapter\File("{$wwwroot}/logs/newemail.log");
     $logger->log($log);
     $logger->close();
 }
开发者ID:Apretaste,项目名称:Core,代码行数:34,代码来源:NewemailTask.php


示例17: _send_message

 /**
  * Sends the HTTP message [Request] to a remote server and processes
  * the response.
  *
  * @param   Request   $request  request to send
  * @param   Response  $request  response to send
  * @return  Response
  */
 public function _send_message(Request $request, Response $response)
 {
     $http_method_mapping = array(HTTP_Request::GET => HTTPRequest::METH_GET, HTTP_Request::HEAD => HTTPRequest::METH_HEAD, HTTP_Request::POST => HTTPRequest::METH_POST, HTTP_Request::PUT => HTTPRequest::METH_PUT, HTTP_Request::DELETE => HTTPRequest::METH_DELETE, HTTP_Request::OPTIONS => HTTPRequest::METH_OPTIONS, HTTP_Request::TRACE => HTTPRequest::METH_TRACE, HTTP_Request::CONNECT => HTTPRequest::METH_CONNECT);
     // Create an http request object
     $http_request = new HTTPRequest($request->uri(), $http_method_mapping[$request->method()]);
     if ($this->_options) {
         // Set custom options
         $http_request->setOptions($this->_options);
     }
     // Set headers
     $http_request->setHeaders($request->headers()->getArrayCopy());
     // Set cookies
     $http_request->setCookies($request->cookie());
     // Set query data (?foo=bar&bar=foo)
     $http_request->setQueryData($request->query());
     // Set the body
     if ($request->method() == HTTP_Request::PUT) {
         $http_request->addPutData($request->body());
     } else {
         $http_request->setBody($request->body());
     }
     try {
         $http_request->send();
     } catch (HTTPRequestException $e) {
         throw new Request_Exception($e->getMessage());
     } catch (HTTPMalformedHeaderException $e) {
         throw new Request_Exception($e->getMessage());
     } catch (HTTPEncodingException $e) {
         throw new Request_Exception($e->getMessage());
     }
     // Build the response
     $response->status($http_request->getResponseCode())->headers($http_request->getResponseHeader())->cookie($http_request->getResponseCookies())->body($http_request->getResponseBody());
     return $response;
 }
开发者ID:artbypravesh,项目名称:morningpages,代码行数:42,代码来源:HTTP.php


示例18: get

 function get($request)
 {
     $response = new Response($request);
     if (isset($this->webcode)) {
         $tour = $this->em->fetchTour($this->webcode);
         echo $format = $request->mostAcceptable(array('json', 'html'));
         switch ($format) {
             case 'json':
                 $response->addHeader('Content-type', 'application/json');
                 $response->body = $tour->__toJSON();
                 break;
             case 'html':
                 $this->tm->smarty->assign('title', 'Tour Query');
                 if (get_class($tour) === "JSONMessage") {
                     $this->tm->smarty->assign('notour', "Tour '" . $this->webcode . "' does not exists!");
                 } elseif (get_class($tour) === "OldTour") {
                     $this->tm->smarty->assign('oldtour', $tour);
                 } elseif (get_class($tour) === "Tour") {
                     $this->tm->smarty->assign('tour', $tour);
                     $this->tm->smarty->assign('markers', $tour->merge());
                 }
                 //  					if()
                 $response->code = Response::OK;
                 $response->addHeader('Content-type', 'text/html');
                 $response->body = $this->tm->render('tour');
         }
     } else {
         $this->tm->smarty->assign('title', 'Tour Query');
         $response->code = Response::OK;
         $response->addHeader('Content-type', 'text/html');
         $response->body = $this->tm->render('tour');
     }
     return $response;
 }
开发者ID:ThomDietrich,项目名称:gctour,代码行数:34,代码来源:tour.php


示例19: command

 /**
  * Call the Artisan  command
  *
  * @param  Request  $request
  * @param  string $command
  */
 public function command(Request $request, $command)
 {
     if (array_key_exists('argument_name', $request->all())) {
         $this->validate($request, ['argument_name' => 'required']);
     }
     if (array_key_exists('argument_id', $request->all())) {
         $this->validate($request, ['argument_id' => 'required']);
     }
     $inputs = $request->except('_token', 'command');
     $params = [];
     foreach ($inputs as $key => $value) {
         if ($value != '') {
             $name = starts_with($key, 'argument') ? substr($key, 9) : '--' . substr($key, 7);
             $params[$name] = $value;
         }
     }
     try {
         Artisan::call($command, $params);
         $output = Artisan::output();
         $http_code = 200;
     } catch (Exception $e) {
         $output = $e->getMessage();
         $http_code = 400;
     }
     if ($request->ajax()) {
         $response = new Response($output, $http_code);
         $response->header('Content-Type', 'text/plain');
         return $response;
     } else {
         return back()->with($http_code == 400 ? 'error' : 'output', $output);
     }
 }
开发者ID:ffogarasi,项目名称:nice-artisan,代码行数:38,代码来源:NiceArtisanController.php


示例20: after

 /**
  * This method gets called after the action is called.
  *
  * @param mixed $response Value returned from the action method.
  * 
  * @return Response $response
  */
 public function after($response)
 {
     // Return if passed a response.
     if ($response instanceof Response) {
         return parent::after($response);
     }
     if ($this->autorender) {
         try {
             $this->view->set_filename(Str::lower(str_replace('_', '/', Inflector::denamespace(str_replace('controller_', '', Str::lower($this->request->controller)))) . DS . str_replace('_', '/', $this->request->action)));
         } catch (FuelException $e) {
         }
     }
     // Inject view into the layout if the main request.
     if ($this->layout instanceof View) {
         if ($this->autorender) {
             try {
                 // Throws exception if there is no view template found.
                 $this->layout->content = $this->view->render();
             } catch (FuelException $e) {
             }
         }
         $this->layout->content_data = $this->view->get();
         $this->response->body($this->layout);
     } else {
         $this->response->body($this->view);
     }
     return parent::after($this->response);
 }
开发者ID:mehulsbhatt,项目名称:volcano,代码行数:35,代码来源:controller.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Resque类代码示例发布时间:2022-05-23
下一篇:
PHP Respond类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap