MediaWiki
REL1_37
ApiFormatFeedWrapper.php
Go to the documentation of this file.
1
<?php
27
class
ApiFormatFeedWrapper
extends
ApiFormatBase
{
28
29
public
function
__construct
(
ApiMain
$main ) {
30
parent::__construct( $main,
'feed'
);
31
}
32
39
public
static
function
setResult
( $result, $feed, $feedItems ) {
40
// Store output in the Result data.
41
// This way we can check during execution if any error has occurred
42
// Disable size checking for this because we can't continue
43
// cleanly; size checking would cause more problems than it'd
44
// solve
45
$result->addValue(
null
,
'_feed'
, $feed, ApiResult::NO_VALIDATE );
46
$result->addValue(
null
,
'_feeditems'
, $feedItems, ApiResult::NO_VALIDATE );
47
}
48
54
public
function
getMimeType
() {
55
return
null
;
56
}
57
63
public
function
canPrintErrors
() {
64
return
false
;
65
}
66
73
public
function
initPrinter
( $unused =
false
) {
74
parent::initPrinter( $unused );
75
76
if
( $this->
isDisabled
() ) {
77
return
;
78
}
79
80
$data = $this->
getResult
()->getResultData();
81
if
( isset( $data[
'_feed'
] ) && isset( $data[
'_feeditems'
] ) ) {
83
$feed = $data[
'_feed'
];
84
$feed->httpHeaders();
85
}
else
{
86
// Error has occurred, print something useful
87
ApiBase::dieDebug
( __METHOD__,
'Invalid feed class/item'
);
88
}
89
}
90
96
public
function
execute
() {
97
$data = $this->
getResult
()->getResultData();
98
if
( isset( $data[
'_feed'
] ) && isset( $data[
'_feeditems'
] ) ) {
100
$feed = $data[
'_feed'
];
101
$items = $data[
'_feeditems'
];
102
103
// execute() needs to pass strings to $this->printText, not produce output itself.
104
ob_start();
105
$feed->outHeader();
106
foreach
( $items as & $item ) {
107
$feed->outItem( $item );
108
}
109
$feed->outFooter();
110
$this->
printText
( ob_get_clean() );
111
}
else
{
112
// Error has occurred, print something useful
113
ApiBase::dieDebug
( __METHOD__,
'Invalid feed class/item'
);
114
}
115
}
116
}
ApiBase\dieDebug
static dieDebug( $method, $message)
Internal code errors should be reported with this method.
Definition
ApiBase.php:1633
ApiBase\getResult
getResult()
Get the result object.
Definition
ApiBase.php:628
ApiFormatBase
This is the abstract base class for API formatters.
Definition
ApiFormatBase.php:30
ApiFormatBase\printText
printText( $text)
Append text to the output buffer.
Definition
ApiFormatBase.php:348
ApiFormatBase\isDisabled
isDisabled()
Whether the printer is disabled.
Definition
ApiFormatBase.php:125
ApiFormatFeedWrapper
This printer is used to wrap an instance of the Feed class.
Definition
ApiFormatFeedWrapper.php:27
ApiFormatFeedWrapper\initPrinter
initPrinter( $unused=false)
This class expects the result data to be in a custom format set by self::setResult() $result['_feed']...
Definition
ApiFormatFeedWrapper.php:73
ApiFormatFeedWrapper\__construct
__construct(ApiMain $main)
Definition
ApiFormatFeedWrapper.php:29
ApiFormatFeedWrapper\getMimeType
getMimeType()
Feed does its own headers.
Definition
ApiFormatFeedWrapper.php:54
ApiFormatFeedWrapper\execute
execute()
This class expects the result data to be in a custom format set by self::setResult() $result['_feed']...
Definition
ApiFormatFeedWrapper.php:96
ApiFormatFeedWrapper\setResult
static setResult( $result, $feed, $feedItems)
Call this method to initialize output data.
Definition
ApiFormatFeedWrapper.php:39
ApiFormatFeedWrapper\canPrintErrors
canPrintErrors()
ChannelFeed doesn't give us a method to print errors in a friendly manner, so just punt errors to the...
Definition
ApiFormatFeedWrapper.php:63
ApiMain
This is the main API class, used for both external and internal processing.
Definition
ApiMain.php:49
includes
api
ApiFormatFeedWrapper.php
Generated on Fri Apr 5 2024 23:39:57 for MediaWiki by
1.9.8