diff options
| author | 2025-09-30 16:59:41 -0400 | |
|---|---|---|
| committer | 2025-09-30 22:59:41 +0200 | |
| commit | 72884813e13596d211471482ffdc6d723ed678c9 (patch) | |
| tree | 043856f23bdcae7f9f88294c47c499657c2d05ff /app/Models | |
| parent | bf6e634e042b726edd97335ac36b2305f8101b3f (diff) | |
Add hook enums (#8036)
- add an enum to handle hook types (enum are available since PHP 8.1)
- change hook calls from string value to enum value
Diffstat (limited to 'app/Models')
| -rw-r--r-- | app/Models/Entry.php | 4 | ||||
| -rw-r--r-- | app/Models/EntryDAO.php | 2 | ||||
| -rw-r--r-- | app/Models/Feed.php | 6 | ||||
| -rw-r--r-- | app/Models/FilterActionsTrait.php | 2 | ||||
| -rw-r--r-- | app/Models/ViewMode.php | 2 |
5 files changed, 8 insertions, 8 deletions
diff --git a/app/Models/Entry.php b/app/Models/Entry.php index 7254dd513..0769762f8 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -818,12 +818,12 @@ HTML; if (!$this->isRead()) { if ($feed->attributeBoolean('read_upon_reception') ?? FreshRSS_Context::userConf()->mark_when['reception']) { $this->_isRead(true); - Minz_ExtensionManager::callHook('entry_auto_read', $this, 'upon_reception'); + Minz_ExtensionManager::callHook(Minz_HookType::EntryAutoRead, $this, 'upon_reception'); } if (!empty($titlesAsRead[$this->title()])) { Minz_Log::debug('Mark title as read: ' . $this->title()); $this->_isRead(true); - Minz_ExtensionManager::callHook('entry_auto_read', $this, 'same_title_in_feed'); + Minz_ExtensionManager::callHook(Minz_HookType::EntryAutoRead, $this, 'same_title_in_feed'); } } FreshRSS_Context::userConf()->applyFilterActions($this); diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index ad1cc4393..f236cd3f3 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -387,7 +387,7 @@ SQL; $values = array_merge($values, $ids); $stm = $this->pdo->prepare($sql); if ($stm !== false && $stm->execute($values)) { - Minz_ExtensionManager::callHook('entries_favorite', $ids, $is_favorite); + Minz_ExtensionManager::callHook(Minz_HookType::EntriesFavorite, $ids, $is_favorite); return $stm->rowCount(); } else { $info = $stm === false ? $this->pdo->errorInfo() : $stm->errorInfo(); diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 2b29f7b22..112da1a00 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -255,7 +255,7 @@ class FreshRSS_Feed extends Minz_Model { $params = ''; if ($this->customFavicon()) { $current = $this->id . Minz_User::name(); - $hookParams = Minz_ExtensionManager::callHook('custom_favicon_hash', $this); + $hookParams = Minz_ExtensionManager::callHook(Minz_HookType::CustomFaviconHash, $this); $params = $hookParams !== null ? $hookParams : $current; } else { $params = $this->website(fallback: true) . $this->proxyParam(); @@ -579,9 +579,9 @@ class FreshRSS_Feed extends Minz_Model { // Do not use `$simplePie->enable_cache(false);` as it would prevent caching in multiuser context $this->clearCache(); } - Minz_ExtensionManager::callHook('simplepie_before_init', $simplePie, $this); + Minz_ExtensionManager::callHook(Minz_HookType::SimplepieBeforeInit, $simplePie, $this); $simplePieResult = $simplePie->init(); - Minz_ExtensionManager::callHook('simplepie_after_init', $simplePie, $this, $simplePieResult); + Minz_ExtensionManager::callHook(Minz_HookType::SimplepieAfterInit, $simplePie, $this, $simplePieResult); if ($simplePieResult === false || $simplePie->get_hash() === '' || !empty($simplePie->error())) { if ($simplePie->status_code() === 429) { diff --git a/app/Models/FilterActionsTrait.php b/app/Models/FilterActionsTrait.php index 3d8257e34..36b3682d8 100644 --- a/app/Models/FilterActionsTrait.php +++ b/app/Models/FilterActionsTrait.php @@ -132,7 +132,7 @@ trait FreshRSS_FilterActionsTrait { case 'read': if (!$entry->isRead()) { $entry->_isRead(true); - Minz_ExtensionManager::callHook('entry_auto_read', $entry, 'filter'); + Minz_ExtensionManager::callHook(Minz_HookType::EntryAutoRead, $entry, 'filter'); } break; case 'star': diff --git a/app/Models/ViewMode.php b/app/Models/ViewMode.php index 54379b130..fde073097 100644 --- a/app/Models/ViewMode.php +++ b/app/Models/ViewMode.php @@ -51,7 +51,7 @@ final class FreshRSS_ViewMode { $modes = self::getDefaultModes(); // Allow extensions to add their own view modes - $extensionModes = Minz_ExtensionManager::callHook('view_modes', []); + $extensionModes = Minz_ExtensionManager::callHook(Minz_HookType::ViewModes, []); if (is_array($extensionModes)) { foreach ($extensionModes as $mode) { if ($mode instanceof FreshRSS_ViewMode) { |
