From a14873d5b4bde01f1470db5a2bb0d49ac0c8cd3c Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 8 Feb 2021 21:06:14 +0300 Subject: [PATCH] more hooks, also add type hint for PluginHost::getInstance() --- classes/article.php | 8 +++++--- classes/pluginhost.php | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/article.php b/classes/article.php index a79241bf6..6729443a1 100755 --- a/classes/article.php +++ b/classes/article.php @@ -731,9 +731,11 @@ class Article extends Handler_Protected { define('ARTICLE_KIND_VIDEO', 2); define('ARTICLE_KIND_YOUTUBE', 3); - foreach (PluginHost::getInstance()->get_hooks(PluginHost::HOOK_ARTICLE_IMAGE) as $p) { - list ($article_image, $article_stream, $content) = $p->hook_article_image($enclosures, $content, $site_url); - } + PluginHost::getInstance()->chain_hooks_callback(PluginHost::HOOK_ARTICLE_IMAGE, + function ($result) use (&$article_image, &$article_stream, &$content) { + list ($article_image, $article_stream, $content) = $result; + }, + $enclosures, $content, $site_url); if (!$article_image && !$article_stream) { $tmpdoc = new DOMDocument(); diff --git a/classes/pluginhost.php b/classes/pluginhost.php index 108d95a88..d94279706 100755 --- a/classes/pluginhost.php +++ b/classes/pluginhost.php @@ -90,7 +90,7 @@ class PluginHost { // } - public static function getInstance() { + public static function getInstance(): PluginHost { if (self::$instance == null) self::$instance = new self();