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


PHP ResponseInterface::write方法代码示例

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


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

示例1: __invoke

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $response->write('<!DOCTYPE HTML>' . PHP_EOL);
     $response->write('<html>' . PHP_EOL);
     if ($next) {
         $response = $next($request, $response);
     }
     $response->write('</html>' . PHP_EOL);
     return $response;
 }
开发者ID:avz-cmf,项目名称:zaboy-middleware,代码行数:16,代码来源:Html.php

示例2: __invoke

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $response->write(PHP_EOL . '<body  class="claro">' . PHP_EOL);
     $response->write('    <h2> Main Request Headers</h2>' . PHP_EOL);
     $response->write('    <div id="MainRequestHeadesrsGrid"></div>' . PHP_EOL);
     $response->write('    <div id="AllType"></div>' . PHP_EOL);
     $next($request, $response);
     $response->write(PHP_EOL . $request->getAttributes() . '</br>' . PHP_EOL);
     $response->write(PHP_EOL . '</body>' . PHP_EOL);
     return $response;
 }
开发者ID:avz-cmf,项目名称:zaboy-middleware,代码行数:17,代码来源:Body.php

示例3: __invoke

 /**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
 {
     $response->write('<head>' . PHP_EOL);
     $response->write('    <title>Title></title>' . PHP_EOL);
     $response->write('    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . PHP_EOL);
     $next($request, $response);
     $response->write(PHP_EOL . '</head>' . PHP_EOL);
     if ($next) {
         return $next($request, $response);
     }
     return $response;
 }
开发者ID:avz-cmf,项目名称:zaboy-middleware,代码行数:18,代码来源:Head.php

示例4: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     $this->logger->info("Company Information page action dispatched");
     // Get Countries from json
     // TODO: Improve - Get Countries from data
     $menu = null;
     try {
         $filename = __DIR__ . '/../Model/scheme/Company/countries.json';
         if (file_exists($filename)) {
             $str = file_get_contents($filename);
             $countries = json_decode($str);
         } else {
             $this->flash->addMessage('error', 'countries.json not found');
         }
     } catch (Exception $e) {
         $this->flash->addMessage('error', 'Error getting Countries. ' . $e->getMessage());
     }
     if (!is_null($this->currentCompany->address)) {
         $address = $this->currentCompany->address->fetch();
     } else {
         $address = $this->addressRepository->create();
     }
     // Get messages
     $messages = $this->flash->getMessages();
     $body = $this->view->fetch('company/information/information.twig', ['flash' => $messages, 'company' => $this->currentCompany, 'address' => $address, 'countries' => $countries->data]);
     return $response->write($body);
     //        $this->view->render($response, 'company/information.twig');
     //        return $response;
 }
开发者ID:EpykOS,项目名称:eelh,代码行数:29,代码来源:CompanyInformationAction.php

示例5: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     $this->id = $args['id'];
     //        $this->logger->info("[" . $this->id . "] - Get data with the weather forecast");
     FileSystemCache::$cacheDir = './cache/tmp';
     $key = FileSystemCache::generateCacheKey('cache-feed-' . $this->id, null);
     $data = FileSystemCache::retrieve($key);
     if ($data === false) {
         $this->data_json = array('datetime' => json_decode(file_get_contents('http://dsx.weather.com/cs/v2/datetime/' . $this->locale . '/' . $args['id'] . ':1:BR'), true), 'now' => json_decode(file_get_contents('http://dsx.weather.com/wxd/v2/MORecord/' . $this->locale . '/' . $args['id'] . ':1:BR'), true), 'forecasts' => json_decode(file_get_contents('http://dsx.weather.com/wxd/v2/15DayForecast/' . $this->locale . '/' . $args['id'] . ':1:BR'), true));
         $data = array('info' => $this->processInfo(), 'now' => $this->processNow(), 'forecasts' => $this->processForecast());
         FileSystemCache::store($key, $data, 1800);
     } else {
         //            $this->logger->info("[" . $this->id . "] - Using cache to generate xml");
     }
     $xmlBuilder = new XmlBuilder('root');
     $xmlBuilder->setSingularizer(function ($name) {
         if ('forecasts' === $name) {
             return 'item';
         }
         return $name;
     });
     $xmlBuilder->load($data);
     $xml_output = $xmlBuilder->createXML(true);
     $response->write($xml_output);
     $response = $response->withHeader('content-type', 'text/xml');
     return $response;
 }
开发者ID:andrearruda,项目名称:Weather-Channel,代码行数:27,代码来源:ForecastAction.php

示例6: render

 /**
  * Render the template.
  *
  * @param string   $name
  * @param string[] $data
  *
  * @throws \LogicException
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function render($name, array $data = [])
 {
     if (!isset($this->response)) {
         throw new \LogicException(sprintf('Invalid %s object instance', ResponseInterface::class));
     }
     return $this->response->write($this->plates->render($name, $data));
 }
开发者ID:projek-xyz,项目名称:slim-plates,代码行数:17,代码来源:Plates.php

示例7: finalize

 /**
  * Finalize response, writes to response given data as json if array is given.
  * Must be public so that error handling can also call.
  * 
  * @param custom $return
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function finalize($return)
 {
     if (is_array($return)) {
         $this->setContentType('application/json');
         $return = json_encode($return);
     }
     return $this->response->write($return);
 }
开发者ID:stenvala,项目名称:deco-essentials,代码行数:15,代码来源:Slim.php

示例8: subpage

 /**
  * Render the subpage page.
  *
  * @param  \Psr\Http\Message\ServerRequestInterface $request
  * @param  \Psr\Http\Message\ResponseInterface $response
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function subpage(Request $request, Response $response)
 {
     $translator = $this->get('translator');
     $data = ['title' => $translator->get('welcome.subpage_text'), 'welcomeMessage' => $translator->get('welcome.subpage_message')];
     $view = View::make('layouts::default', $data);
     $view->nest('body', 'welcome.subpage', $data);
     return $response->write($view);
 }
开发者ID:bvqbao,项目名称:app-skeleton,代码行数:15,代码来源:Welcome.php

示例9: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     $this->logger->info("Status api action dispatched");
     $status = \App\Model\LogQuery::create()->orderByTimestamp('desc')->limit(1)->find()->toArray();
     $status = $status[0];
     $status['Data'] = json_decode($status['Data']);
     $response->withHeader('Content-Type', 'application/json');
     $response->write(json_encode($status));
     return $response;
 }
开发者ID:KingNoosh,项目名称:StirHack,代码行数:10,代码来源:StatusAction.php

示例10: get

 /**
  * @param \Psr\Http\Message\ServerRequestInterface $request
  * @param \Psr\Http\Message\ResponseInterface      $response
  * @param array                                    $args
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function get(Request $request, Response $response, $args)
 {
     $this->logger->info(substr(strrchr(rtrim(__CLASS__, '\\'), '\\'), 1) . ': ' . __FUNCTION__);
     $path = explode('/', $request->getUri()->getPath())[1];
     $result = $this->dataaccess->get($path, $args);
     if ($result == null) {
         return $response->withStatus(404);
     } else {
         return $response->write(json_encode($result));
     }
 }
开发者ID:pabloroca,项目名称:slim3-simple-rest-skeleton,代码行数:18,代码来源:_Controller.php

示例11: dispatch

 /**
  * Handle notes validation, creation and update
  *
  * @param  \Psr\Http\Message\ServerRequestInterface $request  PSR7 request
  * @param  \Psr\Http\Message\ResponseInterface      $response PSR7 response
  * @param  callable                                 $next     Next middleware
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function dispatch(Request $request, Response $response, $args)
 {
     $id = isset($args['id']) ? (int) $args['id'] : null;
     $input = $request->getParsedBody();
     $validator = v::key('body', v::stringType()->notEmpty()->length(5, null, true));
     $validator->assert($input);
     if ($id === null) {
         $note = $this->create($input);
     } else {
         $note = $this->update($input, $id);
     }
     return $response->write(json_encode([$note]));
 }
开发者ID:paulochavesbr,项目名称:notes-api,代码行数:22,代码来源:SaveAction.php

示例12: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     $user = $this->container->get('currentUser');
     $id = isset($args['id']) ? (int) $args['id'] : null;
     $notes = [];
     if ($id) {
         $note = Note::where('id', $id)->where('user_id', $user->userId)->firstOrFail();
         $notes = [$note];
     } else {
         $notes = User::findOrFail($user->userId)->notes;
     }
     return $response->write(json_encode(['message' => 'List of Notes', 'data' => $notes]));
 }
开发者ID:aodkrisda,项目名称:notes-api,代码行数:13,代码来源:IndexAction.php

示例13: __invoke

 /**
  * @param  Container         $container A DI (Pimple) container.
  * @param  RequestInterface  $request   A PSR-7 compatible Request instance.
  * @param  ResponseInterface $response  A PSR-7 compatible Response instance.
  * @return ResponseInterface
  */
 public function __invoke(Container $container, RequestInterface $request, ResponseInterface $response)
 {
     $config = $this->config();
     // Handle explicit redirects
     if (!empty($config['redirect'])) {
         $uri = $this->parseRedirect($config['redirect'], $request);
         if ($uri) {
             return $response->withRedirect($uri, $config['redirect_mode']);
         }
     }
     $templateContent = $this->templateContent($container, $request);
     $response->write($templateContent);
     return $response;
 }
开发者ID:locomotivemtl,项目名称:charcoal-app,代码行数:20,代码来源:TemplateRoute.php

示例14: showAction

 /**
  * Show member action - 'api_member_show'
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param int $id member id
  *
  * @return \Psr\Http\Message\MessageInterface
  *
  * @throws ResourceNotFoundException
  */
 public function showAction(ServerRequestInterface $request, ResponseInterface $response, $id)
 {
     /** @var MemberManager $manager */
     $manager = $this->get('member.manager');
     /** @var Serializer $serializer */
     $serializer = $this->get('serializer');
     $member = $manager->findMemberByActive($id);
     if (!$member) {
         $this->getMonolog()->warning('Member not found', ['id' => $id]);
         throw new ResourceNotFoundException('Member not found');
     }
     $context = SerializationContext::create()->enableMaxDepthChecks()->setGroups(array('Default'));
     return $response->write($serializer->serialize($member, 'json', $context));
 }
开发者ID:myovchev,项目名称:zaralab-api,代码行数:25,代码来源:MemberController.php

示例15: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     // Get Cuisine Types from json
     $cuisineTypes = Utils::getCuisineTypes();
     $dressCodes = Utils::getDressCodes();
     $reservations = Utils::getReservations();
     $alcoholTypes = Utils::getAlcoholTypes();
     $musicTypes = Utils::getMusicTypes();
     $this->logger->info("Company Environment page action dispatched");
     // Get messages
     $messages = $this->flash->getMessages();
     $body = $this->view->fetch('company/environment/environment.twig', ['flash' => $messages, 'company' => $this->currentCompany, 'cuisineTypes' => $cuisineTypes->data, 'dressCodes' => $dressCodes->data, 'reservations' => $reservations->data, 'alcoholTypes' => $alcoholTypes->data, 'musicTypes' => $musicTypes->data]);
     return $response->write($body);
 }
开发者ID:EpykOS,项目名称:eelh,代码行数:14,代码来源:CompanyEnvironmentAction.php


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