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


PHP Response::render方法代码示例

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


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

示例1: __invoke

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

示例2: testRenderException

 public function testRenderException()
 {
     $request = $this->makeRequest();
     $response = new Response($request);
     $this->setExpectedException('UnderflowException', 'You must set controller before calling this method.');
     $response->render('tpl');
 }
开发者ID:ansarbek,项目名称:beaver-mysql-logger,代码行数:7,代码来源:ResponseTest.php

示例3: __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

示例4: __invoke

 /**
  * @param Request    $req
  * @param Response   $res
  * @param \Exception $e
  *
  * @return Response
  */
 public function __invoke($req, $res, \Exception $e)
 {
     $this->app['logger']->error('An uncaught exception occurred while handling a request.', ['exception' => $e]);
     if ($req->isHtml()) {
         $res->render(new View('exception', ['title' => 'Internal Server Error', 'exception' => $e]));
     }
     return $res->setCode(500);
 }
开发者ID:idealistsoft,项目名称:framework-bootstrap,代码行数:15,代码来源:ExceptionHandler.php

示例5: render

 /**
  * Returns the rendered html
  * @return the rendered html
  */
 public function render()
 {
     parent::render();
     if ($this->renderAs === 'blank') {
         $template = new \OCP\Template($this->appName, $this->templateName);
     } else {
         $template = new \OCP\Template($this->appName, $this->templateName, $this->renderAs);
     }
     foreach ($this->params as $key => $value) {
         $template->assign($key, $value, false);
     }
     return $template->fetchPage();
 }
开发者ID:nanowish,项目名称:apps,代码行数:17,代码来源:template.response.php

示例6: render

 /**
  * Returns the rendered json
  * @return the rendered json
  */
 public function render()
 {
     parent::render();
     ob_start();
     if ($this->error) {
         \OCP\JSON::error($this->data);
     } else {
         \OCP\JSON::success($this->data);
     }
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
开发者ID:nanowish,项目名称:apps,代码行数:17,代码来源:json.response.php

示例7: run

 public function run()
 {
     try {
         if (!$this->router->match($this->request->getMethod(), $this->request->getUrl())) {
             throw new \Exception('No route match url', 404);
         }
         $controllerClass = '\\Controllers\\' . ucfirst($this->router->getController()) . 'Controller';
         $action = $this->router->getAction() . 'Action';
         $controller = new $controllerClass($this);
         $response = call_user_func_array(array($controller, $action), $this->router->getParameters());
         $response->setApp($this);
         $response->render();
     } catch (\Exception $e) {
         $code = $e->getCode() === 404 ? 404 : 500;
         $response = new Response($code . '.html', array('msg' => $e->getMessage()));
         $response->setApp($this);
         $response->render();
     }
 }
开发者ID:arzzzen,项目名称:geometria,代码行数:19,代码来源:App.php

示例8: run

 /**
  * 1) Initialise the Request
  * 2) Grab the AssetType based on the request and initialise it
  * 3) Instantiate the Response class, set the headers, and then return the content
  *
  * Rap everything in a Try/Catch block for error handling
  *
  * @param Request $Request
  * @param array $options
  *
  * @return string
  *
  * @catch NotFoundException
  * @catch ErrorException
  */
 public static function run(Request $Request, $options = array())
 {
     try {
         /**
          * Merge in default options
          */
         $options = array_merge(self::$defaultOptions, $options);
         /**
          * Set the header controller. Can be overwritten by the dispatcher options
          */
         if (isset($options['headerController']) && $options['headerController'] instanceof Asset\HeaderSetter) {
             $headerController = $options['headerController'];
         } else {
             $headerController = new Asset\HeaderSetter();
         }
         /**
          * Initialise the Request
          */
         $Request->init();
         /**
          * Grab the correct AssetType
          */
         $AssetType = Asset\Registry::getClass($Request);
         /**
          * Initialise the AssetType
          */
         $AssetType->init();
         /**
          * Create a response
          */
         $Response = new Response($AssetType);
         $Response->setHeaderController($headerController);
         /**
          * Set the headers if told to do so
          */
         if ($options['setHeaders']) {
             /**
              * Set the headers.
              */
             $Response->setHeaders($options['maxAge']);
         }
         /**
          * If the content hasn't been modified return null so only headers are sent
          * otherwise return the content
          */
         return $Response->notModified ? null : $Response->render();
     } catch (Asset\NotFoundException $e) {
         if (isset($headerController) && $headerController instanceof Asset\HeaderSetter) {
             $headerController->statusCode('HTTP/1.0', 404, 'Not Found');
             $headerController->headerField('Status', '404 Not Found');
         }
         return 'Not Found Error: ' . static::getErrors($e);
     } catch (Asset\Type\CompilationException $e) {
         if (isset($AssetType) && $AssetType instanceof Asset\Type) {
             $AssetType->cleanUpAfterError();
         }
         return 'Compilation Error: ' . static::getErrors($e);
     } catch (ErrorException $e) {
         return 'Error: ' . static::getErrors($e);
     }
 }
开发者ID:is00hcw,项目名称:munee,代码行数:76,代码来源:Dispatcher.php

示例9: get

 public function get()
 {
     $response = new Response();
     return $response->render('partials/table', array('this' => $this), $fetch = true);
 }
开发者ID:erichub,项目名称:Presence-V-0.1,代码行数:5,代码来源:Table.class.php

示例10: getSummary

 public function getSummary()
 {
     $response = new Response();
     return $response->render('partials/debug.tpl', array('profiler' => $this), true);
 }
开发者ID:vincenthib,项目名称:visiteztokyo,代码行数:5,代码来源:Profiler.class.php

示例11: render

 public function render()
 {
     $vars = $this->getVars();
     $response = new Response();
     return $response->render('partials/form.tpl', $vars, $fetch = true);
 }
开发者ID:vincenthib,项目名称:framework,代码行数:6,代码来源:Form.class.php

示例12: run

 public function run()
 {
     // Se usa un contexto global para el render
     return Response::render('homepage');
 }
开发者ID:foreverphp,项目名称:foreverphp,代码行数:5,代码来源:StartView.php

示例13: render

 /**
  * Simply sets the headers and returns the file contents
  * @return the file contents
  */
 public function render()
 {
     parent::render();
     return $this->content;
 }
开发者ID:nanowish,项目名称:apps,代码行数:9,代码来源:textdownload.response.php

示例14: header

<?php

try {
    require_once '../config/core.conf.php';
    header('Content-type: text/html; charset=' . Lang::$encoding);
    //$profiler = new Profiler();
    $controller = new ActionController();
    $controller->handle();
    //$profiler->stop();
    //echo $profiler->getSummary();
} catch (Exception $e) {
    $response = new Response();
    if ($e instanceof AutoloadException || $e instanceof ViewException) {
        $response->render('500');
    }
    if ($e instanceof ActionControllerException) {
        $response->render('404');
    }
    $class_exception = get_class($e);
    $msg_exception = $class_exception . ' : ' . $e->getMessage();
    Logger::log($msg_exception);
    if (CORE_DEBUG) {
        echo '<pre>' . $msg_exception . '</pre>';
    }
}
开发者ID:vincenthib,项目名称:framework,代码行数:25,代码来源:index.php

示例15: redirect

 /**
  * Returns a RedirectResponse to the given URL.
  *
  * @param string  $url    The URL to redirect to
  * @param integer $status The status code to use for the Response
  *
  * @return RedirectResponse
  */
 public function redirect($url, $status = 302)
 {
     $this->redirectWithHtml($url);
     $this->response->addHeader('location', $url);
     return $this->response->render();
 }
开发者ID:ebuildy,项目名称:ebuildy,代码行数:14,代码来源:Controller.php


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