aboutsummaryrefslogtreecommitdiff
path: root/docs/en/developers
diff options
context:
space:
mode:
Diffstat (limited to 'docs/en/developers')
-rw-r--r--docs/en/developers/03_Backend/05_Extensions.md15
1 files changed, 13 insertions, 2 deletions
diff --git a/docs/en/developers/03_Backend/05_Extensions.md b/docs/en/developers/03_Backend/05_Extensions.md
index 770ea29cc..602625cf8 100644
--- a/docs/en/developers/03_Backend/05_Extensions.md
+++ b/docs/en/developers/03_Backend/05_Extensions.md
@@ -132,15 +132,26 @@ The `Minz_Extension` abstract class defines another set of methods that should n
You can register at the FreshRSS event system in an extensions `init()` method, to manipulate data when some of the core functions are executed.
```php
-class HelloWorldExtension extends Minz_Extension
+final class HelloWorldExtension extends Minz_Extension
{
+ #[\Override]
public function init(): void {
$this->registerHook('entry_before_display', [$this, 'renderEntry']);
+ $this->registerHook('check_url_before_add', [self::class, 'checkUrl']);
}
+
public function renderEntry(FreshRSS_Entry $entry): FreshRSS_Entry {
- $entry->_content('<h1>Hello World</h1>' . $entry->content());
+ $message = $this->getUserConfigurationValue('message');
+ $entry->_content("<h1>{$message}</h1>" . $entry->content());
return $entry;
}
+
+ public static function checkUrlBeforeAdd(string $url): string {
+ if (str_starts_with($url, 'https://')) {
+ return $url;
+ }
+ return null;
+ }
}
```