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


PHP Response::setPublic方法代码示例

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


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

示例1: testDisableCache

 public function testDisableCache()
 {
     // disable cache
     $this->structure->getCacheLifeTime()->willReturn(0);
     $this->response->setPublic()->shouldNotBeCalled();
     $this->response->setMaxAge($this->maxAge)->shouldNotBeCalled();
     $this->response->setSharedMaxAge($this->sharedMaxAge)->shouldNotBeCalled();
     $this->handler->updateResponse($this->response->reveal(), $this->structure->reveal());
 }
开发者ID:ollietb,项目名称:sulu,代码行数:9,代码来源:PublicHandlerTest.php

示例2: __construct

 /**
  * Constructor
  *
  * @param IrisEntityManager $irisEntityManager
  * @param Cache $cache
  * @param int $httpCacheMaxAgeInSeconds
  */
 public function __construct(IrisEntityManager $irisEntityManager, Cache $cache, $httpCacheMaxAgeInSeconds = 3600)
 {
     $this->irisEntityManager = $irisEntityManager;
     $this->cache = $cache;
     $this->httpCacheMaxAgeInSeconds = $httpCacheMaxAgeInSeconds;
     // Set up response with public cache parameters
     $this->response = new Response();
     $this->response->setPublic()->setMaxAge($httpCacheMaxAgeInSeconds)->setSharedMaxAge($httpCacheMaxAgeInSeconds);
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:16,代码来源:SystemBrand.php

示例3: __construct

 /**
  * Constructor
  *
  * @param SystemBrand $systemBrandService
  * @param int $httpCacheMaxAgeInSeconds
  */
 public function __construct(SystemBrand $systemBrandService, $httpCacheMaxAgeInSeconds = 3600)
 {
     $this->systemBrandService = $systemBrandService;
     $this->irisEntityManager = $this->systemBrandService->irisEntityManager;
     $this->cache = $this->systemBrandService->cache;
     $this->httpCacheMaxAgeInSeconds = $httpCacheMaxAgeInSeconds;
     // Set up response with public cache parameters
     $this->response = new Response();
     $this->response->setPublic()->setMaxAge($httpCacheMaxAgeInSeconds)->setSharedMaxAge($httpCacheMaxAgeInSeconds);
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:16,代码来源:AbstractBrandController.php

示例4: handle

 function handle(HttpFoundation\Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     $path = ltrim($request->getPathInfo(), '/');
     $asset = $this->environment->find($path, array("bundled" => true));
     $debug = $request->query->get("debug", false);
     $cache = !$request->query->get("nocache", false);
     if (!$asset or $path == '') {
         return $this->renderNotFound($request);
     }
     if ($debug) {
         $this->environment->bundleProcessors->clear();
     }
     $lastModified = new \DateTime();
     $lastModified->setTimestamp($asset->getLastModified());
     $response = new HttpFoundation\Response();
     $response->setPublic();
     $response->setLastModified($lastModified);
     if ($cache and $response->isNotModified($request)) {
         return $response;
     }
     $response->setContent($asset->getBody());
     $response->headers->set('Content-Type', $asset->getContentType());
     $response->prepare($request);
     return $response;
 }
开发者ID:chh,项目名称:pipe,代码行数:25,代码来源:Server.php

示例5: handle

 function handle(Request $request, $type = HttpFoundation::MASTER_REQUEST, $catch = true)
 {
     $pathinfo = $request->getPathInfo();
     if (preg_match('{^/_pipe/(.+)$}', $pathinfo, $matches)) {
         $path = $matches[1];
         if (!$path or !($asset = $this->env->find($path, array('bundled' => true)))) {
             $this->log->error("pipe: Asset '{$path}' not found");
             return new Response('Not Found', 404);
         }
         $lastModified = new \DateTime();
         $lastModified->setTimestamp($asset->getLastModified());
         $response = new Response();
         $response->setPublic();
         $response->setLastModified($lastModified);
         if ($response->isNotModified($request)) {
             $this->log->info("pipe: 302 {$path}");
             return $response;
         }
         $start = microtime(true);
         $response->setContent($asset->getBody());
         $this->log->info(sprintf('pipe: Rendered "%s" in %d seconds', $path, microtime(true) - $start));
         $response->headers->set('Content-Type', $asset->getContentType());
         $response->prepare($request);
         return $response;
     }
     return $this->app->handle($request, $type, $catch);
 }
开发者ID:chh,项目名称:pipe,代码行数:27,代码来源:Middleware.php

示例6: indexAction

 /**
  * @Route("/{_locale}", name="donate_front_home", defaults={"_locale"="fr"}, requirements = {"_locale" = "fr|en"})
  */
 public function indexAction(Request $request, $_locale)
 {
     //cache validation tjrs public, c'est l'ESI qui gère la sidebar
     $response = new Response();
     $response->setPublic();
     $response->setSharedMaxAge(3600);
     $data = new Customer();
     $layoutMgr = $this->get('donate_core.layout.manager');
     $layout = $layoutMgr->getDefault($_locale);
     $form = $this->createForm(new DonationType($this->get('translator')), $data, array('civilities' => $this->getParameter('donate_front.form.civility'), 'equivalences' => $this->get('donate_core.equivalence.factory')->getAll(), 'payment_methods' => $this->get('donate_core.payment_method_discovery')->getEnabledMethods(), 'affectations' => $layout->getAffectations()));
     $form->handleRequest($request);
     if ($form->isValid()) {
         $intentMgr = $this->get('donate_core.intent_manager');
         $paymentMethods = $this->get('donate_core.payment_method_discovery')->getEnabledMethods();
         foreach ($paymentMethods as $pm) {
             if ($form->get('payment_method')->get($pm->getId())->isClicked()) {
                 $amount = $form->get('tunnels')->get($pm->getTunnel())->getData();
                 $intent = $intentMgr->newIntent($amount, $pm->getId());
                 $intent->setFiscalReceipt($form['erf']->getData());
                 //add affectation if any
                 $intent->setAffectationCode($form['affectations']->getData());
                 $data->addIntent($intent);
                 $em = $this->getDoctrine()->getManager();
                 $em->persist($data);
                 $em->flush();
                 $response = $intentMgr->handle($intent);
                 return $response;
             }
         }
     }
     return $this->render('DonateFrontBundle:Form:index.html.twig', array('form' => $form->createView()), $response);
 }
开发者ID:bco-trey,项目名称:edonate,代码行数:35,代码来源:FormController.php

示例7: resultatAction

 public function resultatAction(Request $request, AbstractTerritoire $territoire)
 {
     $response = new Response();
     $response->setLastModified($this->get('repository.cache_info')->getLastModified($territoire));
     $response->setPublic();
     if ($response->isNotModified($request)) {
         return $response;
     }
     $allEcheances = $this->get('repository.echeance')->getAll();
     $form = $this->createForm(new EcheanceChoiceType($allEcheances), array(), array('method' => 'GET'));
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid() && ($data = $form->getData())) {
         $reference = $data['comparaison'] ? $data['comparaison']->getNom() : null;
         $echeances = $data['echeances'];
         if (!in_array($reference, $echeances->toArray(), true)) {
             $reference = null;
         }
     } else {
         $echeances = array_filter($allEcheances, function ($element) {
             return $element->getType() !== Echeance::MUNICIPALES;
         });
         $reference = null;
         $form->get('echeances')->setData(new ArrayCollection($echeances));
     }
     $results = $this->getResults($territoire, $echeances);
     return $this->render('resultat.html.twig', array('form' => $form->createView(), 'resultats' => $results, 'territoire' => $territoire->getNom(), 'reference' => $reference), $response);
 }
开发者ID:AlexisEidelman,项目名称:dataelections.fr,代码行数:27,代码来源:ResultatController.php

示例8: apidocAction

 function apidocAction()
 {
     $response = new Response();
     $response->setPublic();
     $response->setMaxAge($this->container->getParameter('cache_expiration'));
     return $this->render('AppBundle:Default:apidoc.html.twig', array("pagetitle" => "API documentation"), $response);
 }
开发者ID:ROMzombie,项目名称:maginationduel-api,代码行数:7,代码来源:DefaultController.php

示例9: getResponse

 /**
  * Handle a request for a file
  *
  * @param Request $request HTTP request
  * @return Response
  */
 public function getResponse($request)
 {
     $response = new Response();
     $response->prepare($request);
     $path = implode('/', $request->getUrlSegments());
     if (!preg_match('~download-file/g(\\d+)$~', $path, $m)) {
         return $response->setStatusCode(400)->setContent('Malformatted request URL');
     }
     $this->application->start();
     $guid = (int) $m[1];
     $file = get_entity($guid);
     if (!$file instanceof ElggFile) {
         return $response->setStatusCode(404)->setContent("File with guid {$guid} does not exist");
     }
     $filenameonfilestore = $file->getFilenameOnFilestore();
     if (!is_readable($filenameonfilestore)) {
         return $response->setStatusCode(404)->setContent('File not found');
     }
     $last_updated = filemtime($filenameonfilestore);
     $etag = '"' . $last_updated . '"';
     $response->setPublic()->setEtag($etag);
     if ($response->isNotModified($request)) {
         return $response;
     }
     $response = new BinaryFileResponse($filenameonfilestore, 200, array(), false, 'attachment');
     $response->prepare($request);
     $expires = strtotime('+1 year');
     $expires_dt = (new DateTime())->setTimestamp($expires);
     $response->setExpires($expires_dt);
     $response->setEtag($etag);
     return $response;
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:38,代码来源:DownloadFileHandler.php

示例10: viewAction

 /**
  * View a single content page
  *
  * This Controller action is being routed to from either our custom ContentRouter,
  * or the ExceptionController.
  * @see Opifer\SiteBundle\Router\ContentRouter
  *
  * @param Request          $request
  * @param ContentInterface $content
  * @param int              $statusCode
  *
  * @return Response
  *
  * @throws \Exception
  */
 public function viewAction(Request $request, ContentInterface $content, $statusCode = 200)
 {
     $version = $request->query->get('_version');
     $debug = $this->getParameter('kernel.debug');
     $contentDate = $content->getUpdatedAt();
     $templateDate = $content->getTemplate()->getUpdatedAt();
     $date = $contentDate > $templateDate ? $contentDate : $templateDate;
     $response = new Response();
     $response->setLastModified($date);
     $response->setPublic();
     if (null === $version && false == $debug && $response->isNotModified($request)) {
         // return the 304 Response immediately
         return $response;
     }
     $version = $request->query->get('_version');
     /** @var Environment $environment */
     $environment = $this->get('opifer.content.block_environment');
     $environment->setObject($content);
     $response->setStatusCode($statusCode);
     if (null !== $version && $this->isGranted('ROLE_ADMIN')) {
         $environment->setDraft(true);
     }
     $environment->load();
     return $this->render($environment->getView(), $environment->getViewParameters(), $response);
 }
开发者ID:Opifer,项目名称:Cms,代码行数:40,代码来源:ContentController.php

示例11: getAction

 /**
  * Get the details of a person.
  *
  * @param int $id The ID of the person as assigned by MyAnimeList
  *
  * @return View
  */
 public function getAction($id)
 {
     // http://myanimelist.net/people/#{id}
     $downloader = $this->get('atarashii_api.communicator');
     try {
         $personDetails = $downloader->fetch('/people/' . $id);
     } catch (Exception\CurlException $e) {
         return $this->view(array('error' => 'network-error'), 500);
     } catch (Exception\ClientErrorResponseException $e) {
         $personDetails = $e->getResponse();
     }
     if (strpos($personDetails, 'This page doesn\'t exist') !== false) {
         return $this->view(array('error' => 'not-found'), 200);
     } else {
         $person = PersonParser::parse($personDetails);
         $response = new Response();
         $response->setPublic();
         $response->setMaxAge(86400);
         //One day
         $response->headers->addCacheControlDirective('must-revalidate', true);
         //Also, set "expires" header for caches that don't understand Cache-Control
         $date = new \DateTime();
         $date->modify('+172800 seconds');
         //two days
         $response->setExpires($date);
         $view = $this->view($person);
         $view->setResponse($response);
         $view->setStatusCode(200);
         return $view;
     }
 }
开发者ID:AnimeNeko,项目名称:atarashii-mal-api,代码行数:38,代码来源:PersonController.php

示例12: indexAction

 public function indexAction()
 {
     $response = new Response($this->dumper->dump(), 200, array('Content-Type' => 'application/xml'));
     $response->setPublic();
     $response->setClientTtl($this->httpCache['ttl']);
     return $response;
 }
开发者ID:silvestra,项目名称:silvestra,代码行数:7,代码来源:SitemapController.php

示例13: getIndicadorAction

 /**
  * @param integer $fichaTec
  * @param string $dimension
  * @Get("/rest-service/data/{id}/{dimension}", options={"expose"=true})
  * @Rest\View
  */
 public function getIndicadorAction(FichaTecnica $fichaTec, $dimension)
 {
     $response = new Response();
     // crea una respuesta con una cabecera ETag y Last-Modified
     // para determinar si se debe calcular el indicador u obtener de la caché
     // para el modo de desarrollo (dev) nunca tomar de caché
     $response->setETag($fichaTec->getId());
     $response->setLastModified($this->get('kernel')->getEnvironment() == 'dev' ? new \DateTime('NOW') : $fichaTec->getUltimaLectura());
     $response->setPublic();
     // verifica que la respuesta no se ha modificado para la petición dada
     if ($response->isNotModified($this->getRequest())) {
         // devuelve inmediatamente la respuesta 304 de la caché
         return $response;
     } else {
         $resp = array();
         $filtro = $this->getRequest()->get('filtro');
         $verSql = $this->getRequest()->get('ver_sql') == 'true' ? true : false;
         if ($filtro == null or $filtro == '') {
             $filtros = null;
         } else {
             $filtrObj = json_decode($filtro);
             foreach ($filtrObj as $f) {
                 $filtros_dimensiones[] = $f->codigo;
                 $filtros_valores[] = $f->valor;
             }
             $filtros = array_combine($filtros_dimensiones, $filtros_valores);
         }
         $em = $this->getDoctrine()->getManager();
         $fichaRepository = $em->getRepository('IndicadoresBundle:FichaTecnica');
         $fichaRepository->crearIndicador($fichaTec, $dimension, $filtros);
         $resp['datos'] = $fichaRepository->calcularIndicador($fichaTec, $dimension, $filtros, $verSql);
         $response->setContent(json_encode($resp));
         return $response;
     }
 }
开发者ID:SM2015,项目名称:Etab-hibrido,代码行数:41,代码来源:IndicadorRESTController.php

示例14: fullTreeAction

 /**
  * @Route("/catalog/fulltree", name="spb_shop_catalog_fulltree")
  */
 public function fullTreeAction()
 {
     $em = $this->getDoctrine()->getManager();
     $repo = $em->getRepository('SpbShopBundle:Category');
     $controller = $this;
     $options = array('decorate' => true, 'rootOpen' => '<ul class="dropdown-menu">', 'rootClose' => '</ul>', 'childOpen' => function ($child) {
         if ($child['rgt'] - $child['lft'] == 1) {
             return '<li>';
         } else {
             return '<li class="dropdown-submenu">';
         }
     }, 'childClose' => '</li>', 'nodeDecorator' => function ($node) use(&$controller) {
         return '<a href="' . $controller->generateUrl('spb_shop_catalog_category', array('slug' => $node['slug'], 'tag' => $node['tag'])) . '">' . $node['title'] . '</a>';
     });
     $htmlTree = $repo->childrenHierarchy(null, false, $options);
     $response = new Response($htmlTree);
     // пометить ответ как public или private
     $response->setPublic();
     //$response->setPrivate();
     //
     // установить max age для private и shared ответов
     $response->setMaxAge(6000);
     $response->setSharedMaxAge(6000);
     // установить специальную директиву Cache-Control
     $response->headers->addCacheControlDirective('must-revalidate', true);
     return $response;
 }
开发者ID:binidini,项目名称:viktis,代码行数:30,代码来源:CatalogController.php

示例15: renderTag

 /**
  * Renders the tag.
  *
  * @param \Netgen\TagsBundle\API\Repository\Values\Tags\Tag $tag
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 protected function renderTag(Tag $tag, Request $request)
 {
     $configResolver = $this->getConfigResolver();
     if ($this->adapter instanceof TagAdapterInterface) {
         $this->adapter->setTag($tag);
     }
     $pager = new Pagerfanta($this->adapter);
     $pager->setMaxPerPage($configResolver->getParameter('tag_view.related_content_list.limit', 'eztags'));
     $pager->setCurrentPage($request->get('page', 1));
     $response = new Response();
     $response->headers->set('X-Tag-Id', $tag->id);
     if ($configResolver->getParameter('tag_view.cache', 'eztags') === true) {
         $response->setPublic();
         if ($configResolver->getParameter('tag_view.ttl_cache', 'eztags') === true) {
             $response->setSharedMaxAge($configResolver->getParameter('tag_view.default_ttl', 'eztags'));
         }
         // Make the response vary against X-User-Hash header ensures that an HTTP
         // reverse proxy caches the different possible variations of the
         // response as it can depend on user role for instance.
         if ($request->headers->has('X-User-Hash')) {
             $response->setVary('X-User-Hash');
         }
         $response->setLastModified($tag->modificationDate);
     }
     return $this->render($configResolver->getParameter('tag_view.template', 'eztags'), array('tag' => $tag, 'pager' => $pager), $response);
 }
开发者ID:umanit,项目名称:TagsBundle,代码行数:34,代码来源:TagViewController.php


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