summaryrefslogtreecommitdiff
path: root/classes/api.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-08 17:03:34 +0300
committerAndrew Dolgov <[email protected]>2021-02-08 17:03:34 +0300
commitfa2ebcd0a25e6c350d7105753ca4f3e37cf7f464 (patch)
treee560e8e9f38b6c890d916e933e991b6bad060286 /classes/api.php
parent363b3629a41a56e3130d6b493f8d0b8a268aa1ed (diff)
api: rewrite a few more hooks
Diffstat (limited to 'classes/api.php')
-rwxr-xr-xclasses/api.php25
1 files changed, 16 insertions, 9 deletions
diff --git a/classes/api.php b/classes/api.php
index 7125e52aa..4b9c44073 100755
--- a/classes/api.php
+++ b/classes/api.php
@@ -352,9 +352,11 @@ class API extends Handler {
$article["content"] = $line["content"];
}
- foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
- $article = $p->hook_render_article_api(array("article" => $article));
- }
+ PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_API,
+ function ($result) use (&$article) {
+ $article = $result;
+ },
+ ["article" => $article]);
$article['content'] = DiskCache::rewriteUrls($article['content']);
@@ -703,9 +705,12 @@ class API extends Handler {
if (!is_numeric($result)) {
while ($line = $result->fetch()) {
$line["content_preview"] = truncate_string(strip_tags($line["content"]), $excerpt_length);
- foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_QUERY_HEADLINES) as $p) {
- $line = $p->hook_query_headlines($line, $excerpt_length, true);
- }
+
+ PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_QUERY_HEADLINES,
+ function ($result) use (&$line) {
+ $line = $result;
+ },
+ $line, $excerpt_length);
$is_updated = ($line["last_read"] == "" &&
($line["unread"] != "t" && $line["unread"] != "1"));
@@ -781,9 +786,11 @@ class API extends Handler {
$headline_row["note"] = $line["note"];
$headline_row["lang"] = $line["lang"];
- foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_RENDER_ARTICLE_API) as $p) {
- $headline_row = $p->hook_render_article_api(array("headline" => $headline_row));
- }
+ PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_RENDER_ARTICLE_API,
+ function ($result) use (&$headline_row) {
+ $headline_row = $result;
+ },
+ ["headline" => $headline_row]);
$headline_row["content"] = DiskCache::rewriteUrls($headline_row['content']);