mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2025-08-06 22:27:42 +02:00
Move 'IVirtualFeed' checks into 'PluginHost::get_feed_handler()'.
This commit is contained in:
parent
dca2ae60a1
commit
5a200755b8
@ -693,9 +693,7 @@ class API extends Handler {
|
||||
|
||||
$handler = PluginHost::getInstance()->get_feed_handler($pfeed_id);
|
||||
|
||||
if ($handler && implements_interface($handler, 'IVirtualFeed')) {
|
||||
/** @var Plugin&IVirtualFeed $handler */
|
||||
|
||||
if ($handler) {
|
||||
$params = array(
|
||||
"feed" => $feed_id,
|
||||
"limit" => $limit,
|
||||
|
@ -106,9 +106,7 @@ class Feeds extends Handler_Protected {
|
||||
$handler = PluginHost::getInstance()->get_feed_handler(
|
||||
PluginHost::feed_to_pfeed_id($feed));
|
||||
|
||||
if ($handler && implements_interface($handler, 'IVirtualFeed')) {
|
||||
/** @var Plugin&IVirtualFeed $handler */
|
||||
|
||||
if ($handler) {
|
||||
$options = array(
|
||||
"limit" => $limit,
|
||||
"view_mode" => $view_mode,
|
||||
@ -939,12 +937,7 @@ class Feeds extends Handler_Protected {
|
||||
} else if (is_numeric($feed) && $feed < PLUGIN_FEED_BASE_INDEX && $feed > LABEL_BASE_INDEX) { // virtual Feed
|
||||
$feed_id = PluginHost::feed_to_pfeed_id($feed);
|
||||
$handler = PluginHost::getInstance()->get_feed_handler($feed_id);
|
||||
if (implements_interface($handler, 'IVirtualFeed')) {
|
||||
/** @var Plugin&IVirtualFeed $handler */
|
||||
return $handler->get_unread($feed_id);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
return $handler ? $handler->get_unread($feed_id) : 0;
|
||||
} else if ($n_feed == Feeds::FEED_RECENTLY_READ) {
|
||||
return 0;
|
||||
// tags
|
||||
|
@ -53,8 +53,7 @@ class Handler_Public extends Handler {
|
||||
$handler = $tmppluginhost->get_feed_handler(
|
||||
PluginHost::feed_to_pfeed_id((int)$feed));
|
||||
|
||||
if ($handler && implements_interface($handler, 'IVirtualFeed')) {
|
||||
/** @var Plugin&IVirtualFeed $handler */
|
||||
if ($handler) {
|
||||
$qfh_ret = $handler->get_headlines(PluginHost::feed_to_pfeed_id((int)$feed), $params);
|
||||
} else {
|
||||
user_error("Failed to find handler for plugin feed ID: $feed", E_USER_ERROR);
|
||||
|
@ -782,12 +782,21 @@ class PluginHost {
|
||||
return $this->feeds[$cat_id] ?? [];
|
||||
}
|
||||
|
||||
// convert feed_id (e.g. -129) to pfeed_id first
|
||||
/**
|
||||
* convert feed_id (e.g. -129) to pfeed_id first
|
||||
*
|
||||
* @return (Plugin&IVirtualFeed)|null
|
||||
*/
|
||||
function get_feed_handler(int $pfeed_id): ?Plugin {
|
||||
foreach ($this->feeds as $cat) {
|
||||
foreach ($cat as $feed) {
|
||||
if ($feed['id'] == $pfeed_id) {
|
||||
if (implements_interface($feed['sender'], 'IVirtualFeed')) {
|
||||
/** @var Plugin&IVirtualFeed $feed['sender'] */
|
||||
return $feed['sender'];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user