mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-31 13:50:23 +02:00
Formats: Remove display & related method (#2776)
Format should not be responsible for sending HTTP response.
This commit is contained in:
@@ -24,9 +24,6 @@ abstract class FormatAbstract implements FormatInterface {
|
||||
/** MIME type of format output */
|
||||
const MIME_TYPE = 'text/plain';
|
||||
|
||||
/** @var string|null $contentType The content type */
|
||||
protected $contentType = null;
|
||||
|
||||
/** @var string $charset The charset */
|
||||
protected $charset;
|
||||
|
||||
@@ -65,18 +62,6 @@ abstract class FormatAbstract implements FormatInterface {
|
||||
return is_null($charset) ? static::DEFAULT_CHARSET : $charset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content type
|
||||
*
|
||||
* @param string $contentType The content type
|
||||
* @return self The format object
|
||||
*/
|
||||
protected function setContentType($contentType){
|
||||
$this->contentType = $contentType;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the last modified time
|
||||
*
|
||||
@@ -87,34 +72,6 @@ abstract class FormatAbstract implements FormatInterface {
|
||||
$this->lastModified = $lastModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send header with the currently specified content type
|
||||
*
|
||||
* @throws \LogicException if the content type is not set
|
||||
* @throws \LogicException if the content type is not a string
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function callContentType(){
|
||||
if(empty($this->contentType))
|
||||
throw new \LogicException('Content-Type is not set!');
|
||||
|
||||
if(!is_string($this->contentType))
|
||||
throw new \LogicException('Content-Type must be a string!');
|
||||
|
||||
header('Content-Type: ' . $this->contentType);
|
||||
}
|
||||
|
||||
/** {@inheritdoc} */
|
||||
public function display(){
|
||||
if ($this->lastModified) {
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s ', $this->lastModified) . 'GMT');
|
||||
}
|
||||
echo $this->stringify();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
|
Reference in New Issue
Block a user