aboutsummaryrefslogtreecommitdiff
path: root/docs/en/developers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-04-10 15:33:43 +0200
committerGravatar GitHub <noreply@github.com> 2024-04-10 15:33:43 +0200
commit350edf398c55b472e19a3017de9b4d2d3420b9e4 (patch)
tree00672f4cba0830e4b39f778e3a36de6b961fc5bb /docs/en/developers
parent8280e3d88edb93211fcf2aec15a7b4c1ae4d3813 (diff)
PHP 8.3 #[\Override] (#6273)
* PHP 8.3 #[\Override] https://php.watch/versions/8.3/override-attr With PHPStan `checkMissingOverrideMethodAttribute` https://phpstan.org/config-reference#checkmissingoverridemethodattribute And modified the call to phpstan-next on the model of https://github.com/FreshRSS/Extensions/pull/228 (more robust than the find method, which gave some strange errors) * Update extension example accordingly
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;
+ }
}
```