本文整理汇总了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);
}
}
示例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());
}
示例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());
}
示例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());
}
示例5: nullifyDates
/**
* @param View $view
*/
private function nullifyDates(View $view)
{
$headers = $view->getHeaders();
unset($headers['date']);
$view->setHeaders($headers);
}
示例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());
}
示例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());
}
示例8: testSetHeaders
public function testSetHeaders()
{
$view = new View();
$headers = array('foo' => 'bar');
$view->setHeaders($headers);
$this->assertEquals($headers, $view->getHeaders());
}
示例9: headersMatches
private function headersMatches(View $subject, $argument)
{
if (isset($argument['headers'])) {
return $this->matcher->match($subject->getHeaders(), $argument['headers']);
}
return true;
}