Skip to content

Commit

Permalink
Add extension hook simplepie_after_init (FreshRSS#7007)
Browse files Browse the repository at this point in the history
* Add extension hook simplepie_after_init
fix FreshRSS#7006

* Add documentation note

* fix doc get_headers

* Syntax void

* Forgotten code
  • Loading branch information
Alkarex authored Nov 21, 2024
1 parent 0f4bcda commit 2781815
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions app/Models/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ public function load(bool $loadDetails = false, bool $noCache = false): ?\Simple
}
Minz_ExtensionManager::callHook('simplepie_before_init', $simplePie, $this);
$simplePieResult = $simplePie->init();
Minz_ExtensionManager::callHook('simplepie_after_init', $simplePie, $this, $simplePieResult);

if ($simplePieResult === false || $simplePie->get_hash() === '' || !empty($simplePie->error())) {
$errorMessage = $simplePie->error();
Expand Down
5 changes: 4 additions & 1 deletion docs/en/developers/03_Backend/05_Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,10 @@ The following events are available:
* `nav_menu` (`function() -> string`): will be executed if the navigation was built.
* `nav_reading_modes` (`function($reading_modes) -> array | null`): **TODO** add documentation.
* `post_update` (`function(none) -> none`): **TODO** add documentation.
* `simplepie_before_init` (`function($simplePie, $feed) -> none`): **TODO** add documentation.
* `simplepie_after_init` (`function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed, bool $result): void`): Triggered after fetching an RSS/Atom feed with SimplePie. Useful for instance to get the HTTP response headers (e.g. `$simplePie->data['headers']`).
* `simplepie_before_init` (`function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed): void`): Triggered before fetching an RSS/Atom feed with SimplePie.

> ℹ️ Note: the `simplepie_*` hooks are only fired for feeds using SimplePie via pull, i.e. normal RSS/Atom feeds. This excludes WebSub (push), and the various HTML or JSON Web scraping methods.
### Injecting CDN content

Expand Down
6 changes: 4 additions & 2 deletions docs/fr/developers/03_Backend/05_Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,10 @@ The following events are available:
* `nav_reading_modes` (`function($reading_modes) -> array | null`): **TODO**
add documentation
* `post_update` (`function(none) -> none`): **TODO** add documentation
* `simplepie_before_init` (`function($simplePie, $feed) -> none`): **TODO**
add documentation
* `simplepie_after_init` (`function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed, bool $result): void`): Triggered after fetching an RSS/Atom feed with SimplePie. Useful for instance to get the HTTP response headers (e.g. `$simplePie->data['headers']`).
* `simplepie_before_init` (`function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed): void`): Triggered before fetching an RSS/Atom feed with SimplePie.

> ℹ️ Note: the `simplepie_*` hooks are only fired for feeds using SimplePie via pull, i.e. normal RSS/Atom feeds. This excludes WebSub (push), and the various HTML or JSON Web scraping methods.
### Writing your own configure.phtml

Expand Down
10 changes: 7 additions & 3 deletions lib/Minz/ExtensionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,14 @@ final class Minz_ExtensionManager {
'list' => array(),
'signature' => 'NoneToNone',
),
'simplepie_before_init' => array( // function($simplePie, $feed) -> none
'list' => array(),
'simplepie_after_init' => [ // function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed, bool $result): void
'list' => [],
'signature' => 'PassArguments',
),
],
'simplepie_before_init' => [ // function(\SimplePie\SimplePie $simplePie, FreshRSS_Feed $feed): void
'list' => [],
'signature' => 'PassArguments',
],
];

/** Remove extensions and hooks from a previous initialisation */
Expand Down

0 comments on commit 2781815

Please sign in to comment.