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


PHP View::getHeaders方法代码示例

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


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

示例1: createResponse

 /**
  * Converts the viewdata to a RSS feed. Modify to suit your datastructure.
  *
  * @return Response
  */
 public function createResponse(ViewHandler $handler, View $view, Request $request)
 {
     if ($view->getData() instanceof Diary) {
         return new Response($this->createFeed($view->getData()), Response::HTTP_OK, $view->getHeaders());
     } else {
         return new Response('Unsupported entity type', Response::HTTP_BAD_REQUEST);
     }
 }
开发者ID:dstansby,项目名称:camdram,代码行数:13,代码来源:ICalViewHandler.php

示例2: createResponse

 /**
  * @param ViewHandler $viewHandler
  * @param View $view
  * @param Request $request
  * @param string $format
  */
 public function createResponse(ViewHandler $handler, View $view, Request $request, $format)
 {
     $fosrestview = '<?xml version="1.0" encoding="ISO-8859-1"?>';
     $fosrestview .= '<rss version="2.0">';
     $fosrestview .= '<channel>';
     $fosrestview .= '<title>Get Afspraken</title>';
     $fosrestview .= '<language>en-us</language>';
     return new Response($fosrestview, 200, $view->getHeaders());
 }
开发者ID:PieterSwitten,项目名称:webandmobile,代码行数:15,代码来源:FosRestView.php

示例3: createResponse

 /**
  * @param ViewHandler $viewHandler
  * @param View $view
  * @param Request $request
  * @param string $format
  *
  * @return Response
  */
 public function createResponse(ViewHandler $handler, View $view, Request $request, $format)
 {
     $rssfeed = '<?xml version="1.0" encoding="UTF-8"?>';
     $rssfeed .= '<rss version="2.0">';
     $rssfeed .= '<channel>';
     $rssfeed .= '<title>My RSS feed</title>';
     $rssfeed .= '<link>http://www.mywebsite.com</link>';
     $rssfeed .= '<description>This is an example RSS feed</description>';
     $rssfeed .= '<language>en-us</language>';
     $rssfeed .= '<copyright>Copyright (C) 2009 mywebsite.com</copyright>';
     return new Response($rssfeed, 200, $view->getHeaders());
 }
开发者ID:almost-online,项目名称:demo.highload,代码行数:20,代码来源:RSSViewHandler.php

示例4: createResponse

 /**
  * Converts the viewdata to a RSS feed. Modify to suit your datastructure.
  *
  * @return Response
  */
 public function createResponse(ViewHandler $handler, View $view, Request $request)
 {
     try {
         $content = $this->createFeed($view->getData());
         $code = Response::HTTP_OK;
     } catch (\Exception $e) {
         if ($this->logger) {
             $this->logger->error($e);
         }
         $content = sprintf('%s:<br/><pre>%s</pre>', $e->getMessage(), $e->getTraceAsString());
         $code = Response::HTTP_BAD_REQUEST;
     }
     return new Response($content, $code, $view->getHeaders());
 }
开发者ID:seydu,项目名称:FOSRestBundle,代码行数:19,代码来源:RssHandler.php

示例5: nullifyDates

 /**
  * @param View $view
  */
 private function nullifyDates(View $view)
 {
     $headers = $view->getHeaders();
     unset($headers['date']);
     $view->setHeaders($headers);
 }
开发者ID:Spomky,项目名称:Sylius,代码行数:9,代码来源:ResourceControllerSpec.php

示例6: testHeadersInConstructorAreAssignedToResponseObject

 public function testHeadersInConstructorAreAssignedToResponseObject()
 {
     $headers = array('foo' => 'bar');
     $expected = array('foo' => array('bar'), 'cache-control' => array('no-cache'));
     $view = new View(null, null, $headers);
     $this->assertEquals($expected, $view->getHeaders());
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:7,代码来源:ViewTest.php

示例7: createResponse

 /**
  * Handles creation of a Response using either redirection or the templating/serializer service
  *
  * @param View    $view
  * @param Request $request
  * @param string  $format
  *
  * @return Response
  */
 public function createResponse(View $view, Request $request, $format)
 {
     $headers = $view->getHeaders();
     if (empty($headers['Content-Type'])) {
         $view->setHeader('Content-Type', $request->getMimeType($format));
     }
     $route = $view->getRoute();
     $location = $route ? $this->getRouter()->generate($route, (array) $view->getData(), true) : $view->getLocation();
     if ($location) {
         return $this->createRedirectResponse($view, $location, $format);
     }
     if ($this->isFormatTemplating($format)) {
         $content = $this->renderTemplate($view, $format);
     } else {
         $serializer = $this->getSerializer($view);
         $content = $serializer->serialize($view->getData(), $format);
     }
     return new Response($content, $this->getStatusCode($view), $view->getHeaders());
 }
开发者ID:naahuc,项目名称:FOSRestBundle,代码行数:28,代码来源:ViewHandler.php

示例8: testSetHeaders

 public function testSetHeaders()
 {
     $view = new View();
     $headers = array('foo' => 'bar');
     $view->setHeaders($headers);
     $this->assertEquals($headers, $view->getHeaders());
 }
开发者ID:hykz,项目名称:Depot,代码行数:7,代码来源:ViewTest.php

示例9: headersMatches

 private function headersMatches(View $subject, $argument)
 {
     if (isset($argument['headers'])) {
         return $this->matcher->match($subject->getHeaders(), $argument['headers']);
     }
     return true;
 }
开发者ID:codifico,项目名称:phpspec-rest-view-extension,代码行数:7,代码来源:RestViewMatcher.php


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