]> git.mxchange.org Git - friendica.git/commitdiff
Fixings
authornupplaPhil <admin@philipp.info>
Thu, 9 Jan 2020 00:48:48 +0000 (01:48 +0100)
committernupplaPhil <admin@philipp.info>
Fri, 10 Jan 2020 12:22:03 +0000 (13:22 +0100)
- Rename "facStorage" to "storageManager"
- Fix indentation
- Fix tests

doc/AddonStorageBackend.md
src/DI.php
src/Model/Attach.php
src/Model/Photo.php
src/Module/Admin/Site.php
src/Worker/CronJobs.php
tests/src/Core/StorageManagerTest.php

index ef1b4454b967468d5a29bd08e6c749b0125ccfb1..f69dfff45a9d03449f51f89d5028c386f0b679cd 100644 (file)
@@ -23,7 +23,7 @@ interface IStorage
        public function getOptions();
        public function saveOptions(array $data);
        public function __toString();
-    public static function getName();
+       public static function getName();
 }
 ```
 
@@ -250,13 +250,13 @@ function samplestorage_install()
        // on addon install, we register our class with name "Sample Storage".
        // note: we use `::class` property, which returns full class name as string
        // this save us the problem of correctly escape backslashes in class name
-       DI::facStorage()->register(SampleStorageBackend::class);
+       DI::storageManager()->register(SampleStorageBackend::class);
 }
 
 function samplestorage_unistall()
 {
        // when the plugin is uninstalled, we unregister the backend.
-       DI::facStorage()->unregister(SampleStorageBackend::class);
+       DI::storageManager()->unregister(SampleStorageBackend::class);
 }
 
 function samplestorage_storage_instance(\Friendica\App $a, array $data)
index 152e705a7bcca8d6b6adf3d39a48f0c9f4fe9d84..b7be36212bbbe6ef4c8c2665d3b294f8baf2020d 100644 (file)
@@ -27,7 +27,7 @@ use Psr\Log\LoggerInterface;
  * @method static Core\L10n\L10n l10n()
  * @method static Core\Process process()
  * @method static Core\Session\ISession session()
- * @method static Core\StorageManager facStorage()
+ * @method static Core\StorageManager storageManager()
  * @method static Database\Database dba()
  * @method static Factory\Mastodon\Account mstdnAccount()
  * @method static Factory\Mastodon\FollowRequest mstdnFollowRequest()
@@ -49,40 +49,40 @@ use Psr\Log\LoggerInterface;
 abstract class DI
 {
        const CLASS_MAPPING = [
-               'app'          => App::class,
-               'auth'         => App\Authentication::class,
-               'args'         => App\Arguments::class,
-               'baseUrl'      => App\BaseURL::class,
-               'mode'         => App\Mode::class,
-               'module'       => App\Module::class,
-               'page'         => App\Page::class,
-               'router'       => App\Router::class,
-               'contentItem'  => Content\Item::class,
-               'bbCodeVideo'  => Content\Text\BBCode\Video::class,
-               'cache'        => Core\Cache\ICache::class,
-               'config'       => Core\Config\IConfiguration::class,
-               'pConfig'      => Core\Config\IPConfiguration::class,
-               'l10n'         => Core\L10n\L10n::class,
-               'lock'         => Core\Lock\ILock::class,
-               'process'      => Core\Process::class,
-               'session'      => Core\Session\ISession::class,
-               'facStorage'   => Core\StorageManager::class,
-               'dba'          => Database\Database::class,
-               'mstdnAccount' => Factory\Mastodon\Account::class,
+               'app'                => App::class,
+               'auth'               => App\Authentication::class,
+               'args'               => App\Arguments::class,
+               'baseUrl'            => App\BaseURL::class,
+               'mode'               => App\Mode::class,
+               'module'             => App\Module::class,
+               'page'               => App\Page::class,
+               'router'             => App\Router::class,
+               'contentItem'        => Content\Item::class,
+               'bbCodeVideo'        => Content\Text\BBCode\Video::class,
+               'cache'              => Core\Cache\ICache::class,
+               'config'             => Core\Config\IConfiguration::class,
+               'pConfig'            => Core\Config\IPConfiguration::class,
+               'l10n'               => Core\L10n\L10n::class,
+               'lock'               => Core\Lock\ILock::class,
+               'process'            => Core\Process::class,
+               'session'            => Core\Session\ISession::class,
+               'storageManager'     => Core\StorageManager::class,
+               'dba'                => Database\Database::class,
+               'mstdnAccount'       => Factory\Mastodon\Account::class,
                'mstdnFollowRequest' => Factory\Mastodon\FollowRequest::class,
                'mstdnRelationship'  => Factory\Mastodon\Relationship::class,
-               'cookie'       => Model\User\Cookie::class,
-               'notify'       => Model\Notify::class,
-               'storage'      => Model\Storage\IStorage::class,
-               'intro'        => Repository\Introduction::class,
-               'activity'     => Protocol\Activity::class,
-               'aclFormatter' => Util\ACLFormatter::class,
-               'dtFormat'     => Util\DateTimeFormat::class,
-               'fs'           => Util\FileSystem::class,
-               'workerLogger' => Util\Logger\WorkerLogger::class,
-               'profiler'     => Util\Profiler::class,
-               'logger'       => LoggerInterface::class,
-               'devLogger'    => '$devLogger',
+               'cookie'             => Model\User\Cookie::class,
+               'notify'             => Model\Notify::class,
+               'storage'            => Model\Storage\IStorage::class,
+               'intro'              => Repository\Introduction::class,
+               'activity'           => Protocol\Activity::class,
+               'aclFormatter'       => Util\ACLFormatter::class,
+               'dtFormat'           => Util\DateTimeFormat::class,
+               'fs'                 => Util\FileSystem::class,
+               'workerLogger'       => Util\Logger\WorkerLogger::class,
+               'profiler'           => Util\Profiler::class,
+               'logger'             => LoggerInterface::class,
+               'devLogger'          => '$devLogger',
        ];
 
        /** @var Dice */
index 7a0446176817a3e4113cf78bc334aa7afe04108a..e98f80a91d1f8914a67141ef00b5d76b0e4a92b1 100644 (file)
@@ -259,7 +259,7 @@ class Attach
                        $items = self::selectToArray(['backend-class','backend-ref'], $conditions);
 
                        foreach($items as $item) {
-                               $backend_class = DI::facStorage()->getByName($item['backend-class'] ?? '');
+                               $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
                                if ($backend_class !== '') {
                                        $fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? '');
                                } else {
@@ -291,7 +291,7 @@ class Attach
                $items = self::selectToArray(['backend-class','backend-ref'], $conditions);
 
                foreach($items as $item) {
-                       $backend_class = DI::facStorage()->getByName($item['backend-class'] ?? '');
+                       $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
                        if ($backend_class !== null) {
                                $backend_class->delete($item['backend-ref'] ?? '');
                        }
index b13aaa79aabe7b7c3b7fc01dd8097a89c85d1e5e..9e26711401cafd618c0e80c7d71c9907d8444b8c 100644 (file)
@@ -179,7 +179,7 @@ class Photo
                        }
                        $data = $i['data'];
                } else {
-                       $backendClass = DI::facStorage()->getByName($photo['backend-class'] ?? '');
+                       $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
                        $backendRef = $photo['backend-ref'] ?? '';
                        $data = $backendClass->get($backendRef);
                }
@@ -272,7 +272,7 @@ class Photo
 
                if (DBA::isResult($existing_photo)) {
                        $backend_ref = (string)$existing_photo["backend-ref"];
-                       $storage = DI::facStorage()->getByName($existing_photo["backend-class"] ?? '');
+                       $storage = DI::storageManager()->getByName($existing_photo["backend-class"] ?? '');
                } else {
                        $storage = DI::storage();
                }
@@ -336,7 +336,7 @@ class Photo
                $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
 
                foreach($photos as $photo) {
-                       $backend_class = DI::facStorage()->getByName($photo['backend-class'] ?? '');
+                       $backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? '');
                        if ($backend_class !== null) {
                                $backend_class->delete($photo["backend-ref"] ?? '');
                        }
@@ -365,7 +365,7 @@ class Photo
                        $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
 
                        foreach($photos as $photo) {
-                               $backend_class = DI::facStorage()->getByName($photo['backend-class'] ?? '');
+                               $backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? '');
                                if ($backend_class !== null) {
                                        $fields["backend-ref"] = $backend_class->put($img->asString(), $photo['backend-ref']);
                                } else {
index e68f37953708501d952136c3bb74aa0fe15e9785..433cddf6f75018e1dce4b3f59a63af2d9c257de7 100644 (file)
@@ -202,7 +202,7 @@ class Site extends BaseAdminModule
                $storagebackend    = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
 
                // save storage backend form
-               if (DI::facStorage()->setBackend($storagebackend)) {
+               if (DI::storageManager()->setBackend($storagebackend)) {
                        $storage_opts     = DI::storage()->getOptions();
                        $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend);
                        $storage_opts_data   = [];
@@ -534,7 +534,7 @@ class Site extends BaseAdminModule
                        $available_storage_backends[''] = L10n::t('Database (legacy)');
                }
 
-               foreach (DI::facStorage()->listBackends() as $name => $class) {
+               foreach (DI::storageManager()->listBackends() as $name => $class) {
                        $available_storage_backends[$name] = $name;
                }
 
index 6fa09197b15dcb23fa1275a76eb59ac1a07b3878..6a8d65464d90378ea180aa3625906e2fb7d19264 100644 (file)
@@ -325,7 +325,7 @@ class CronJobs
        private static function moveStorage()
        {
                $current = DI::storage();
-               $moved = DI::facStorage()->move($current);
+               $moved = DI::storageManager()->move($current);
 
                if ($moved) {
                        Worker::add(PRIORITY_LOW, "CronJobs", "move_storage");
index 2d131c632541a8465d3ce870c8cecb9b18c959ed..083d12d5797b16f7da63dbbdbcf53e2f07d47c4b 100644 (file)
@@ -28,7 +28,6 @@ use Friendica\Test\Util\SampleStorageBackend;
  * @todo Rework Hook:: methods to dynamic to remove the separated process annotation
  *
  * @runTestsInSeparateProcesses
- * @preserveGlobalState disabled
  */
 class StorageManagerTest extends DatabaseTest
 {