From 3c1599323bddbe7cc1b09d2280ecc0701f23f46f Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 18 Nov 2024 22:28:35 +0000 Subject: [PATCH] Fix docs for themes and theme_admin() --- doc/AddonStorageBackend.md | 42 +++++++++++++++++++------------------- doc/autoloader.md | 4 ++-- view/theme/frio/config.php | 4 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/doc/AddonStorageBackend.md b/doc/AddonStorageBackend.md index c3a6d1639c..5053b641cb 100644 --- a/doc/AddonStorageBackend.md +++ b/doc/AddonStorageBackend.md @@ -126,14 +126,14 @@ Override the two necessary instances: ```php use Friendica\Core\Storage\Capability\ICanWriteToStorage; -abstract class StorageTest +abstract class StorageTest { // returns an instance of your newly created storage class abstract protected function getInstance(); // Assertion for the option array you return for your new StorageClass abstract protected function assertOption(ICanWriteToStorage $storage); -} +} ``` ## Exception handling @@ -158,7 +158,7 @@ Example: ```php use Friendica\Core\Storage\Capability\ICanWriteToStorage; -class ExampleStorage implements ICanWriteToStorage +class ExampleStorage implements ICanWriteToStorage { public function get(string $reference) : string { @@ -168,7 +168,7 @@ class ExampleStorage implements ICanWriteToStorage throw new \Friendica\Core\Storage\Exception\StorageException(sprintf('The Example Storage throws an exception for reference %s', $reference), 500, $exception); } } -} +} ``` ## Example @@ -200,11 +200,11 @@ class SampleStorageBackend implements ICanWriteToStorage /** * SampleStorageBackend constructor. - * + * * You can add here every dynamic class as dependency you like and add them to a private field - * Friendica automatically creates these classes and passes them as argument to the constructor + * Friendica automatically creates these classes and passes them as argument to the constructor */ - public function __construct(string $filename) + public function __construct(string $filename) { $this->filename = $filename; } @@ -215,7 +215,7 @@ class SampleStorageBackend implements ICanWriteToStorage // a config key return file_get_contents($this->filename); } - + public function put(string $data, string $reference = '') { if ($reference === '') { @@ -224,13 +224,13 @@ class SampleStorageBackend implements ICanWriteToStorage // we don't save $data ! return $reference; } - + public function delete(string $reference) { // we pretend to delete the data return true; } - + public function __toString() { return self::NAME; @@ -261,11 +261,11 @@ class SampleStorageBackendConfig implements ICanConfigureStorage /** * SampleStorageBackendConfig constructor. - * + * * You can add here every dynamic class as dependency you like and add them to a private field - * Friendica automatically creates these classes and passes them as argument to the constructor + * Friendica automatically creates these classes and passes them as argument to the constructor */ - public function __construct(IManageConfigValues $config, L10n $l10n) + public function __construct(IManageConfigValues $config, L10n $l10n) { $this->config = $config; $this->l10n = $l10n; @@ -289,12 +289,12 @@ class SampleStorageBackendConfig implements ICanConfigureStorage ], ]; } - + public function saveOptions(array $data) { // the keys in $data are the same keys we defined in getOptions() $newfilename = trim($data['filename']); - + // this function should always validate the data. // in this example we check if file exists if (!file_exists($newfilename)) { @@ -302,9 +302,9 @@ class SampleStorageBackendConfig implements ICanConfigureStorage // ['optionname' => 'error message'] return ['filename' => 'The file doesn\'t exists']; } - + $this->config->set('storage', 'samplestorage', $newfilename); - + // no errors, return empty array return []; } @@ -341,13 +341,13 @@ function samplestorage_storage_uninstall() DI::storageManager()->unregister(SampleStorageBackend::class); } -function samplestorage_storage_instance(App $a, array &$data) +function samplestorage_storage_instance(AppHelper $appHelper, array &$data) { $config = new SampleStorageBackendConfig(DI::l10n(), DI::config()); $data['storage'] = new SampleStorageBackendConfig($config->getFileName()); } -function samplestorage_storage_config(App $a, array &$data) +function samplestorage_storage_config(AppHelper $appHelper, array &$data) { $data['storage_config'] = new SampleStorageBackendConfig(DI::l10n(), DI::config()); } @@ -360,7 +360,7 @@ function samplestorage_storage_config(App $a, array &$data) use Friendica\Core\Storage\Capability\ICanWriteToStorage; use Friendica\Test\src\Core\Storage\StorageTest; -class SampleStorageTest extends StorageTest +class SampleStorageTest extends StorageTest { // returns an instance of your newly created storage class protected function getInstance() @@ -382,5 +382,5 @@ class SampleStorageTest extends StorageTest ], ], $storage->getOptions()); } -} +} ``` diff --git a/doc/autoloader.md b/doc/autoloader.md index 954c28813c..5bc0bfe9b3 100644 --- a/doc/autoloader.md +++ b/doc/autoloader.md @@ -46,9 +46,9 @@ The code will be something like: // mod/network.php getAll(); diff --git a/view/theme/frio/config.php b/view/theme/frio/config.php index 8556420a1e..a2e120735c 100644 --- a/view/theme/frio/config.php +++ b/view/theme/frio/config.php @@ -92,7 +92,7 @@ function theme_admin_post() } } -function theme_content(App $a): string +function theme_content(AppHelper $appHelper): string { if (!DI::userSession()->getLocalUserId()) { return ''; @@ -115,7 +115,7 @@ function theme_content(App $a): string return frio_form($arr); } -function theme_admin(): string +function theme_admin(AppHelper $appHelper): string { if (!DI::userSession()->getLocalUserId()) { return '';