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


PHP Response::__construct方法代码示例

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


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

示例1: __construct

 /**
  * Constructor.
  *
  * @param mixed   $data    The response data
  * @param int     $status  The response status code
  * @param array   $headers An array of response headers
  */
 public function __construct(array $responses = array(), $status = 200, $headers = array())
 {
     parent::__construct('', $status, $headers);
     foreach ($responses as $response) {
         $this->addResponse($response);
     }
 }
开发者ID:xpopov,项目名称:couchdb-endpoint,代码行数:14,代码来源:MultipartMixed.php

示例2: __construct

 /**
  * BlobResponse constructor.
  *
  * @param string $documentPath The path of the document to encode as B64
  * @param int    $status
  * @param array  $headers
  *
  */
 public function __construct($documentPath, $status = 200, array $headers = array())
 {
     $content = base64_encode(file_get_contents($documentPath));
     $finfoMineType = finfo_open(FILEINFO_MIME_TYPE);
     $headers['Content-Type'] = finfo_file($finfoMineType, $documentPath);
     parent::__construct($content, $status, $headers);
 }
开发者ID:ScreamZ,项目名称:SecureDownloadBundle,代码行数:15,代码来源:BlobResponse.php

示例3: __construct

 /**
  *
  * @param string $path
  * @param string $filename
  * @param int $cachetime time in seconds (1 year by default)
  */
 public function __construct($path, $filename = null, $cachetime = 31536000)
 {
     parent::__construct();
     if (!is_file($path)) {
         throw new FileNotFoundException($path);
     }
     $this->file = new SplFileInfo($path);
     if (empty($filename)) {
         $filename = $this->file->getBasename();
     }
     // last modified
     $lastModified = $this->file->getMTime();
     $dateLastModified = new \DateTime();
     $dateLastModified->setTimestamp($lastModified);
     $this->setLastModified($dateLastModified);
     // etag
     $etag = dechex($lastModified);
     $this->setEtag($etag);
     $this->setFileCacheTime($cachetime);
     $mimeType = Fn::fileMimeType($filename);
     // headers
     $this->setContentLength($this->file->getSize());
     $this->setContentType($mimeType);
     $this->setContentDispositionInline($filename);
 }
开发者ID:arnapou,项目名称:gw2tools,代码行数:31,代码来源:ResponseFile.php

示例4: __construct

 /**
  * Constructor
  *
  * @param int $ttlInSeconds
  * @param string $content
  * @param int $status
  * @param array $headers
  */
 public function __construct($ttlInSeconds, $content = '', $status = 200, $headers = array())
 {
     $now = gmdate('D, d M Y H:i:s \\G\\M\\T', time());
     $expires = gmdate('D, d M Y H:i:s \\G\\M\\T', time() + $ttlInSeconds);
     $headers = array_merge(array('Content-Type' => 'text/css', 'Pragma' => 'cache', 'Cache-Control' => 'public', 'Date' => $now, 'Last-Modified' => $now, 'Expires' => $expires), $headers);
     parent::__construct($content, $status, $headers);
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:15,代码来源:PublicCacheResponse.php

示例5: __construct

 /**
  * Create a simple html page, if title is given, a small skeleton is added.
  * In this case you'll only have to provide the content of the body element.
  * In other cases you'll have to provide the full html.
  * @param string $body
  * @param string $title
  */
 public function __construct($body, $title = null)
 {
     if ($title !== null) {
         $body = sprintf('<!DOCTYPE html><html><head><title>%s</title></head><body>%s</body></html>', $title, $body);
     }
     parent::__construct($body, 200, ['Content-Type' => 'text/html']);
 }
开发者ID:tweedegolf,项目名称:okoabundle,代码行数:14,代码来源:HtmlResponse.php

示例6: __construct

 /**
  * Export Response
  *
  * @param array  $data           Data list
  * @param string $fileName       Name of file
  * @param string $type
  * @param string $encodingFrom   Encode from charset
  * @param string $enclosure      Enclosure
  * @param string $delimiter      Delimiter
  * @param bool   $enableDownload Enable download
  */
 public function __construct(array $data = NULL, $fileName = 'export', $type = self::TYPE_CSV, $encodingFrom = 'UTF-8', $enclosure = '"', $delimiter = ',', $enableDownload = true)
 {
     parent::__construct();
     $this->setEncodingFrom($encodingFrom);
     $this->setType($type);
     switch ($type) {
         case self::TYPE_CSV:
             $this->setDelimiter($delimiter);
             $this->setEnclosure($enclosure);
             $this->setFileName($fileName . ".csv");
             if ($data) {
                 $this->setCsv($data);
             }
             break;
         case self::TYPE_XLS:
             $this->setFileName($fileName . ".xls");
             if ($data) {
                 $this->setXls($data);
             }
             break;
     }
     if ($enableDownload) {
         $this->enableDownload();
     }
 }
开发者ID:mapbender,项目名称:fom,代码行数:36,代码来源:ExportResponse.php

示例7: __construct

 /**
  * Construct the basic instance properties.
  *
  * @param array|null  $content              The response content {@see setFinalContent()}
  * @param int|null    $status               Status for this response.
  * @param array       $headers              Headers specific to this response.
  * @param array       $headersGlobal        The global headers configured.
  * @param array       $headersTypeSpecific  The type-specific headers configured.
  * @param string|null $charsetGlobal        The global charset configured.
  * @param string|null $charsetTypeSpecific  The type-specific charset configured.
  * @param float|null  $protocolGlobal       The global charset configured.
  * @param float|null  $protocolTypeSpecific The type-specific charset configured.
  *
  * @throws \InvalidArgumentException When the HTTP status code is not valid
  *
  * @api
  */
 public function __construct($content = null, $status = null, $headers = [], $headersGlobal = [], $headersTypeSpecific = [], $charsetGlobal = null, $charsetTypeSpecific = null, $protocolGlobal = null, $protocolTypeSpecific = null)
 {
     parent::__construct(null, $this->getFinalStatus($status), $this->getFinalHeaders($headersGlobal, $headersTypeSpecific, $headers));
     $this->setData($content);
     $this->setCharset($this->getFinalCharset($charsetGlobal, $charsetTypeSpecific));
     $this->setProtocolVersion($this->getFinalProtocol($protocolGlobal, $protocolTypeSpecific));
 }
开发者ID:scr-be,项目名称:mantle-bundle,代码行数:24,代码来源:YamlResponse.php

示例8: __construct

 /**
  * Construct calendar response
  *
  * @param Calendar $calendar Calendar
  * @param int      $status   Response status
  * @param array    $headers  Response headers
  */
 public function __construct(Calendar $calendar, $status = 200, $headers = array())
 {
     $this->calendar = $calendar;
     $content = utf8_encode($calendar->createCalendar());
     $headers = array_merge($this->getDefaultHeaders(), $headers);
     parent::__construct($content, $status, $headers);
 }
开发者ID:dyvelop,项目名称:icalcreator-bundle,代码行数:14,代码来源:CalendarResponse.php

示例9: __construct

 /**
  * Constructor.
  *
  * @param Template $template An object that is able to render a template with context
  * @param array    $context  An array of context variables
  * @param array    $globals  An array of global context variables
  * @param int      $status   The response status code
  * @param array    $headers  An array of response headers
  */
 public function __construct(Template $template, array $context = [], array $globals = [], $status = 200, $headers = [])
 {
     parent::__construct(null, $status, $headers);
     $this->template = $template;
     $this->context = $context;
     $this->addGlobals($globals);
 }
开发者ID:nectd,项目名称:nectd-web,代码行数:16,代码来源:BoltResponse.php

示例10: __construct

 public function __construct($content = '', $status = 200, $headers = array())
 {
     parent::__construct($content, $status, $headers);
     if ($this->headers->get('Content-Type') !== 'application/xml') {
         $this->headers->set('Content-Type', 'application/xml');
     }
 }
开发者ID:surfnet,项目名称:stepup-saml-bundle,代码行数:7,代码来源:XMLResponse.php

示例11: __construct

 /**
  * Constructor
  *
  * @param mixed   $data    The response data
  * @param integer $status  The response status code
  * @param array   $headers An array of response headers
  */
 public function __construct($events = array(), $status = 200, $headers = array())
 {
     parent::__construct('', $status, $headers);
     $this->headers->set('Content-Type', 'text/calendar');
     $this->headers->set('Content-Disposition', 'attachment; filename=calendar.ics');
     $this->setEvents($events);
 }
开发者ID:matthieuprat,项目名称:temtspcalendarexporter,代码行数:14,代码来源:Response.php

示例12: __construct

 public function __construct(TemplateEngineInterface $template = null, $view = null, $viewdata = [], $status = 200, $headers = array())
 {
     $this->template = $template;
     $this->view = $view;
     $this->viewdata = $viewdata;
     parent::__construct('', $status, $headers);
 }
开发者ID:laasti,项目名称:response,代码行数:7,代码来源:ViewResponse.php

示例13: __construct

 /**
  * Constructor.
  *
  * @param Thumbnail $thumbnail        The thumbnail
  * @param int       $status           The response status code
  * @param array     $headers          An array of response headers
  * @param bool      $public           Thumbnails are public by default
  * @param bool      $autoEtag         Whether the ETag header should be automatically set
  * @param bool      $autoLastModified Whether the Last-Modified header should be automatically set
  */
 public function __construct(Thumbnail $thumbnail, $status = 200, $headers = [], $public = true, $autoEtag = false, $autoLastModified = true)
 {
     parent::__construct(null, $status, $headers);
     $this->setThumbnail($thumbnail, $autoEtag, $autoLastModified);
     if ($public) {
         $this->setPublic();
     }
 }
开发者ID:pkdevboxy,项目名称:bolt-thumbs,代码行数:18,代码来源:Response.php

示例14: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct(base64_decode(static::IMAGE_CONTENT));
     $this->headers->set('Content-Type', static::CONTENT_TYPE);
     $this->setPrivate();
     $this->headers->addCacheControlDirective('no-cache', true);
     $this->headers->addCacheControlDirective('must-revalidate', true);
 }
开发者ID:gander,项目名称:symfony-transparent-pixel-response,代码行数:11,代码来源:TransparentPixelResponse.php

示例15: __construct

 public function __construct($message, $where = '', $type = '')
 {
     $content = new \stdClass();
     $content->type = 'exception';
     $content->message = $message;
     $content->where = $where;
     parent::__construct(json_encode($content), 500, array('Content-Type' => 'text/javascript'));
 }
开发者ID:makasim,项目名称:php-direct,代码行数:8,代码来源:ErrorResponse.php


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