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


PHP View::setHeader方法代码示例

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


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

示例1: handleExtension

 /**
  * @param ViewHandler $viewHandler
  * @param View $view
  * @param Request $request
  * @param string $format
  *
  * @return Response
  */
 public function handleExtension(ViewHandler $handler, View $view, Request $request, $format)
 {
     if (in_array("application/vnd.bpi.api+xml", $request->getAcceptableContentTypes())) {
         $view->setHeader("Content-Type", "application/vnd.bpi.api+xml");
     }
     return $handler->createResponse($view, $request, "xml");
 }
开发者ID:rimi-itk,项目名称:bpi-web-service,代码行数:15,代码来源:BPIViewHandler.php

示例2: build

 /**
  * @return View
  */
 public function build()
 {
     if ($this->setVersion && $this->singleDocument != null) {
         $this->view->setHeader('ETag', hash('sha256', $this->singleDocument->getId() . $this->singleDocument->getVersion()));
     }
     return $this->view;
 }
开发者ID:EightArmCode,项目名称:librarian,代码行数:10,代码来源:ViewBuilder.php

示例3: setContentRangeHeader

 /**
  * @param View $view
  * @param int $offset
  * @param int $limit
  * @param int $total
  */
 protected function setContentRangeHeader(View $view, $offset, $limit, $total)
 {
     $offset = (int) $offset;
     $total = (int) $total;
     $needRange = $limit >= 0 || $offset >= 0;
     if ($needRange) {
         if ($limit === null) {
             $end = $total - 1;
         } else {
             $end = $offset + $limit - 1;
             $end = min($end, $total - 1);
         }
         if ($limit !== null && (int) $limit === 0) {
             $offset = '';
             $end = '';
         }
         $view->setHeader('Content-Range', "items {$offset}-{$end}/{$total}");
     }
     $needPartialContentStatus = $offset > 0 || $limit !== null && $total > $limit;
     if ($needPartialContentStatus) {
         $view->setStatusCode(Response::HTTP_PARTIAL_CONTENT);
     }
 }
开发者ID:glavweb,项目名称:GlavwebRestBundle,代码行数:29,代码来源:GlavwebRestController.php

示例4: 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

示例5: postFlyAction

 /**
  * Creates a new fly from the submitted data.
  *
  * @throws AccessDeniedException
  *
  * @ApiDoc(
  *   resource = true,
  *   input = "Flyaround\DefaultBundle\Form\Type\FlyType",
  *   statusCodes = {
  *     200 = "Returned when successful",
  *     400 = "Returned when the form has errors"
  *   }
  * )
  *
  * @Annotations\View(
  *   template = "FlyaroundDefaultBundle:Fly:newFly.html.twig",
  *   statusCode = Codes::HTTP_BAD_REQUEST
  * )
  *
  * @param Request $request the request object
  *
  * @return FormTypeInterface|RouteRedirectView
  */
 public function postFlyAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $fly = new Fly();
     $form = $this->createForm(new FlyType(), $fly);
     $form->submit($request);
     if ($form->isValid()) {
         $em->persist($fly);
         $em->flush();
         return new Response('{"id": ' . $fly->getId() . '}', 201, array('Access-Control-Allow-Origin' => '*'));
     }
     $view = new View(array('form' => $form));
     $view->setHeader('Access-Control-Allow-Origin', '*');
     $group = $this->container->get('security.context')->isGranted('ROLE_API') ? 'restapi' : 'standard';
     $view->getSerializationContext()->setGroups(array('Default', $group));
     return $view;
 }
开发者ID:sev28,项目名称:flyaround_s2,代码行数:40,代码来源:FlyController.php


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