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


PHP Response::setCallback方法代码示例

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


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

示例1: error

 protected function error($error = null, $code = 200)
 {
     $this->builder->createPartial('body', 'error')->getParamManager()->setParams(['error' => $error === null ? _i('We encountered an unexpected error.') : $error]);
     $this->response->setStatusCode($code);
     if ($this->response instanceof StreamedResponse) {
         $this->response->setCallback(function () {
             $this->builder->stream();
         });
     } else {
         $this->response->setContent($this->builder->build());
     }
     return $this->response;
 }
开发者ID:KasaiDot,项目名称:FoolSlide2,代码行数:13,代码来源:Reader.php

示例2: render

 /**
  * Renders a view and returns a Response.
  *
  * To stream a view, pass an instance of StreamedResponse as a third argument.
  *
  * @param string   $view       The view name
  * @param array    $parameters An array of parameters to pass to the view
  * @param Response $response   A Response instance
  *
  * @return Response A Response instance
  */
 public function render($view, array $parameters = array(), Response $response = null)
 {
     $twig = $this['twig'];
     if ($response instanceof StreamedResponse) {
         $response->setCallback(function () use($twig, $view, $parameters) {
             $twig->display($view, $parameters);
         });
     } else {
         if (null === $response) {
             $response = new Response();
         }
         $response->setContent($twig->render($view, $parameters));
     }
     return $response;
 }
开发者ID:php-go,项目名称:php-go,代码行数:26,代码来源:TwigTrait.php

示例3: render

 public function render($view, array $parameters = [], Response $response = null)
 {
     /** @var \Twig_Environment $twig */
     $twig = $this->app['twig'];
     if ($response instanceof StreamedResponse) {
         $response->setCallback(function () use($twig, $view, $parameters) {
             $twig->display($view, $parameters);
         });
         return $response;
     }
     if (null === $response) {
         $response = new Response();
     }
     $response->setContent($twig->render($view, $parameters));
     return $response;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:16,代码来源:BaseController.php

示例4: render

 /**
  * Renders a view and returns a Response.
  *
  * To stream a view, pass an instance of StreamedResponse as a third argument.
  *
  * @param string   $view       The view name
  * @param array    $parameters An array of parameters to pass to the view
  * @param Response $response   A Response instance
  *
  * @return Response A Response instance
  */
 public function render($view, array $parameters = [], Response $response = null)
 {
     $twig = $this['twig'];
     if ($response instanceof StreamedResponse) {
         $response->setCallback(function () use($twig, $view, $parameters) {
             $twig->display($view, $parameters);
         });
         return $response;
     }
     if (null === $response) {
         $response = new Response();
     }
     if ($this->hasCachingEnabled()) {
         $response->setTtl($this['http_cache.default_ttl']);
     }
     $response->setContent($twig->render($view, $parameters));
     return $response;
 }
开发者ID:jtallant,项目名称:skimpy-engine,代码行数:29,代码来源:CacheableTwigResponses.php

示例5: serveFromCache

 /**
  * Generate a response object for a cached image
  *
  * @param  String  $path Path to the cached image
  * @return Boolean
  */
 private function serveFromCache($path)
 {
     //try and load the image from the cache
     if ($this->cache->has($path)) {
         $file = $this->cache->get($path);
         $lastModified = new \DateTime();
         $lastModified->setTimestamp($file->getTimestamp());
         $this->setHttpCacheHeaders($lastModified, md5($this->getCachePath() . $lastModified->getTimestamp()), $this->maxAge);
         // Respond with 304 not modified
         if ($this->response->isNotModified($this->request)) {
             return true;
         }
         $this->response = new StreamedResponse();
         // Set the headers
         $this->response->headers->set('Content-Type', $file->getMimetype());
         $this->response->headers->set('Content-Length', $file->getSize());
         $this->setHttpCacheHeaders($lastModified, md5($this->getCachePath() . $lastModified->getTimestamp()), $this->maxAge);
         $this->response->setCallback(function () use($file) {
             fpassthru($file->readStream());
         });
         return true;
     }
     return false;
 }
开发者ID:diarmuidie,项目名称:imagerack-kernel,代码行数:30,代码来源:Server.php

示例6: radix_search


//.........这里部分代码省略.........
     }
     if ($search['tripcode']) {
         array_push($title, sprintf(_i('with the tripcode ‘%s’'), e($search['tripcode'])));
     }
     if ($search['filename']) {
         array_push($title, sprintf(_i('with the filename ‘%s’'), e($search['filename'])));
     }
     if ($search['image']) {
         array_push($title, sprintf(_i('with the image hash ‘%s’'), e($search['image'])));
     }
     if ($search['deleted'] == 'deleted') {
         array_push($title, _i('that have been deleted'));
     }
     if ($search['deleted'] == 'not-deleted') {
         array_push($title, _i('that has not been deleted'));
     }
     if ($search['ghost'] == 'only') {
         array_push($title, _i('that are by ghosts'));
     }
     if ($search['ghost'] == 'none') {
         array_push($title, _i('that are not by ghosts'));
     }
     if ($search['type'] == 'sticky') {
         array_push($title, _i('that were stickied'));
     }
     if ($search['type'] == 'op') {
         array_push($title, _i('that are only OP posts'));
     }
     if ($search['type'] == 'posts') {
         array_push($title, _i('that are only non-OP posts'));
     }
     if ($search['filter'] == 'image') {
         array_push($title, _i('that do not contain images'));
     }
     if ($search['filter'] == 'text') {
         array_push($title, _i('that only contain images'));
     }
     if ($search['capcode'] == 'user') {
         array_push($title, _i('that were made by users'));
     }
     if ($search['capcode'] == 'mod') {
         array_push($title, _i('that were made by mods'));
     }
     if ($search['capcode'] == 'admin') {
         array_push($title, _i('that were made by admins'));
     }
     if ($search['start']) {
         array_push($title, sprintf(_i('posts after %s'), e($search['start'])));
     }
     if ($search['end']) {
         array_push($title, sprintf(_i('posts before %s'), e($search['end'])));
     }
     if ($search['order'] == 'asc') {
         array_push($title, _i('in ascending order'));
     }
     if (!empty($title)) {
         $title = sprintf(_i('Searching for posts %s.'), implode(' ' . _i('and') . ' ', $title));
     } else {
         $title = _i('Displaying all posts with no filters applied.');
     }
     if ($this->radix) {
         $this->builder->getProps()->addTitle($title);
     } else {
         $this->builder->getProps()->addTitle('Global Search » ' . $title);
     }
     if ($board->getSearchCount() > 5000) {
         $search_title = sprintf(_i('%s <small>Returning only first %d of %d results found.</small>', $title, $this->preferences->get('foolfuuka.sphinx.max_matches', 5000), $board->getSearchCount()));
     } else {
         $search_title = sprintf(_i('%s <small>%d results found.</small>', $title, $board->getSearchCount()));
     }
     $this->param_manager->setParam('section_title', $search_title);
     $main_partial = $this->builder->createPartial('body', 'board');
     $main_partial->getParamManager()->setParam('board', $board->getComments());
     $pagination = $search;
     unset($pagination['page']);
     $pagination_arr = [];
     $pagination_arr[] = $this->radix !== null ? $this->radix->shortname : '_';
     $pagination_arr[] = 'search';
     foreach ($pagination as $key => $item) {
         if ($item || $item === 0) {
             $pagination_arr[] = rawurlencode($key);
             if (is_array($item)) {
                 $item = implode('.', $item);
             }
             if ($key == 'poster_ip') {
                 $item = Inet::dtop($item);
             }
             $pagination_arr[] = rawurlencode($item);
         }
     }
     $pagination_arr[] = 'page';
     $this->param_manager->setParam('pagination', ['base_url' => $this->uri->create($pagination_arr), 'current_page' => $search['page'] ?: 1, 'total' => ceil($board->getCount() / 25)]);
     $this->param_manager->setParam('modifiers', ['post_show_board_name' => $this->radix === null, 'post_show_view_button' => true]);
     $this->profiler->logMem('Controller Chan $this', $this);
     $this->profiler->log('Controller Chan::search End');
     $this->response->setCallback(function () {
         $this->builder->stream();
     });
     return $this->response;
 }
开发者ID:procod3R,项目名称:FoolFuuka,代码行数:101,代码来源:Chan.php

示例7: response

 /**
  * Makes a JSON response, with either data or an error, never both.
  *
  * @param array $array The data to wrap in the response.
  * @return Symfony\Component\HttpFoundation\Response
  */
 private function response($array)
 {
     $json_encodeOptions = isset($this->config['jsonoptions']) ? $this->config['jsonoptions'] : JSON_PRETTY_PRINT;
     $json = json_encode($array, $json_encodeOptions);
     if (isset($array['errors'])) {
         $status = isset($array['errors']['status']) ? $array['errors']['status'] : 400;
         $response = new Response($json, $status);
     } else {
         $response = new Response($json, 201);
     }
     if (!empty($this->config['headers']) && is_array($this->config['headers'])) {
         foreach ($this->config['headers'] as $header => $value) {
             $response->headers->set($header, $value);
         }
     }
     if ($callback = $this->request->get('callback')) {
         $response->setCallback($callback);
     }
     return $response;
 }
开发者ID:andyjessop,项目名称:jsonapi,代码行数:26,代码来源:Extension.php

示例8: render

 /**
  * Renders a view and returns a Response.
  *
  * To stream a view, pass an instance of StreamedResponse as a third argument.
  *
  * @param string $view The view name
  * @param array $parameters An array of parameters to pass to the view
  * @param Response $response A Response instance
  *
  * @return Response A Response instance
  */
 public function render($view, array $parameters = array(), Response $response = null)
 {
     $twig = $this['twig'];
     // twigファイルのソースコードを読み込み, 文字列化.
     $source = $twig->getLoader()->getSource($view);
     // イベントの実行.
     // プラグインにはテンプレートファイル名、文字列化されたtwigファイル、パラメータを渡す
     $event = new TemplateEvent($view, $source, $parameters, $response);
     $eventName = $view;
     if ($this->isAdminRequest()) {
         // 管理画面の場合、event名に「Admin/」を付ける
         $eventName = 'Admin/' . $view;
     }
     $this['monolog']->debug('Template Event Name : ' . $eventName);
     $this['eccube.event.dispatcher']->dispatch($eventName, $event);
     if ($response instanceof StreamedResponse) {
         $response->setCallback(function () use($twig, $view, $parameters) {
             $twig->display($view, $parameters);
         });
     } else {
         if (null === $response) {
             $response = new Response();
         }
         // プラグインで変更された文字列から, テンプレートオブジェクトを生成
         $template = $twig->createTemplate($event->getSource());
         // レンダリング実行.
         $content = $template->render($event->getParameters());
         $response->setContent($content);
     }
     return $response;
 }
开发者ID:shhirose,项目名称:ec-cube,代码行数:42,代码来源:ApplicationTrait.php


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