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