當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。