- Rename "facStorage" to "storageManager"
- Fix indentation
- Fix tests
This commit is contained in:
nupplaPhil 2020-01-09 01:48:48 +01:00
parent bfae6766bf
commit 016cfcd846
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
7 changed files with 45 additions and 46 deletions

View file

@ -250,13 +250,13 @@ function samplestorage_install()
// on addon install, we register our class with name "Sample Storage". // on addon install, we register our class with name "Sample Storage".
// note: we use `::class` property, which returns full class name as string // note: we use `::class` property, which returns full class name as string
// this save us the problem of correctly escape backslashes in class name // 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() function samplestorage_unistall()
{ {
// when the plugin is uninstalled, we unregister the backend. // 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) function samplestorage_storage_instance(\Friendica\App $a, array $data)

View file

@ -27,7 +27,7 @@ use Psr\Log\LoggerInterface;
* @method static Core\L10n\L10n l10n() * @method static Core\L10n\L10n l10n()
* @method static Core\Process process() * @method static Core\Process process()
* @method static Core\Session\ISession session() * @method static Core\Session\ISession session()
* @method static Core\StorageManager facStorage() * @method static Core\StorageManager storageManager()
* @method static Database\Database dba() * @method static Database\Database dba()
* @method static Factory\Mastodon\Account mstdnAccount() * @method static Factory\Mastodon\Account mstdnAccount()
* @method static Factory\Mastodon\FollowRequest mstdnFollowRequest() * @method static Factory\Mastodon\FollowRequest mstdnFollowRequest()
@ -66,7 +66,7 @@ abstract class DI
'lock' => Core\Lock\ILock::class, 'lock' => Core\Lock\ILock::class,
'process' => Core\Process::class, 'process' => Core\Process::class,
'session' => Core\Session\ISession::class, 'session' => Core\Session\ISession::class,
'facStorage' => Core\StorageManager::class, 'storageManager' => Core\StorageManager::class,
'dba' => Database\Database::class, 'dba' => Database\Database::class,
'mstdnAccount' => Factory\Mastodon\Account::class, 'mstdnAccount' => Factory\Mastodon\Account::class,
'mstdnFollowRequest' => Factory\Mastodon\FollowRequest::class, 'mstdnFollowRequest' => Factory\Mastodon\FollowRequest::class,

View file

@ -259,7 +259,7 @@ class Attach
$items = self::selectToArray(['backend-class','backend-ref'], $conditions); $items = self::selectToArray(['backend-class','backend-ref'], $conditions);
foreach($items as $item) { foreach($items as $item) {
$backend_class = DI::facStorage()->getByName($item['backend-class'] ?? ''); $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
if ($backend_class !== '') { if ($backend_class !== '') {
$fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? ''); $fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? '');
} else { } else {
@ -291,7 +291,7 @@ class Attach
$items = self::selectToArray(['backend-class','backend-ref'], $conditions); $items = self::selectToArray(['backend-class','backend-ref'], $conditions);
foreach($items as $item) { foreach($items as $item) {
$backend_class = DI::facStorage()->getByName($item['backend-class'] ?? ''); $backend_class = DI::storageManager()->getByName($item['backend-class'] ?? '');
if ($backend_class !== null) { if ($backend_class !== null) {
$backend_class->delete($item['backend-ref'] ?? ''); $backend_class->delete($item['backend-ref'] ?? '');
} }

View file

@ -179,7 +179,7 @@ class Photo
} }
$data = $i['data']; $data = $i['data'];
} else { } else {
$backendClass = DI::facStorage()->getByName($photo['backend-class'] ?? ''); $backendClass = DI::storageManager()->getByName($photo['backend-class'] ?? '');
$backendRef = $photo['backend-ref'] ?? ''; $backendRef = $photo['backend-ref'] ?? '';
$data = $backendClass->get($backendRef); $data = $backendClass->get($backendRef);
} }
@ -272,7 +272,7 @@ class Photo
if (DBA::isResult($existing_photo)) { if (DBA::isResult($existing_photo)) {
$backend_ref = (string)$existing_photo["backend-ref"]; $backend_ref = (string)$existing_photo["backend-ref"];
$storage = DI::facStorage()->getByName($existing_photo["backend-class"] ?? ''); $storage = DI::storageManager()->getByName($existing_photo["backend-class"] ?? '');
} else { } else {
$storage = DI::storage(); $storage = DI::storage();
} }
@ -336,7 +336,7 @@ class Photo
$photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions); $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
foreach($photos as $photo) { foreach($photos as $photo) {
$backend_class = DI::facStorage()->getByName($photo['backend-class'] ?? ''); $backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? '');
if ($backend_class !== null) { if ($backend_class !== null) {
$backend_class->delete($photo["backend-ref"] ?? ''); $backend_class->delete($photo["backend-ref"] ?? '');
} }
@ -365,7 +365,7 @@ class Photo
$photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions); $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
foreach($photos as $photo) { foreach($photos as $photo) {
$backend_class = DI::facStorage()->getByName($photo['backend-class'] ?? ''); $backend_class = DI::storageManager()->getByName($photo['backend-class'] ?? '');
if ($backend_class !== null) { if ($backend_class !== null) {
$fields["backend-ref"] = $backend_class->put($img->asString(), $photo['backend-ref']); $fields["backend-ref"] = $backend_class->put($img->asString(), $photo['backend-ref']);
} else { } else {

View file

@ -202,7 +202,7 @@ class Site extends BaseAdminModule
$storagebackend = Strings::escapeTags(trim($_POST['storagebackend'] ?? '')); $storagebackend = Strings::escapeTags(trim($_POST['storagebackend'] ?? ''));
// save storage backend form // save storage backend form
if (DI::facStorage()->setBackend($storagebackend)) { if (DI::storageManager()->setBackend($storagebackend)) {
$storage_opts = DI::storage()->getOptions(); $storage_opts = DI::storage()->getOptions();
$storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend); $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $storagebackend);
$storage_opts_data = []; $storage_opts_data = [];
@ -534,7 +534,7 @@ class Site extends BaseAdminModule
$available_storage_backends[''] = L10n::t('Database (legacy)'); $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; $available_storage_backends[$name] = $name;
} }

View file

@ -325,7 +325,7 @@ class CronJobs
private static function moveStorage() private static function moveStorage()
{ {
$current = DI::storage(); $current = DI::storage();
$moved = DI::facStorage()->move($current); $moved = DI::storageManager()->move($current);
if ($moved) { if ($moved) {
Worker::add(PRIORITY_LOW, "CronJobs", "move_storage"); Worker::add(PRIORITY_LOW, "CronJobs", "move_storage");

View file

@ -28,7 +28,6 @@ use Friendica\Test\Util\SampleStorageBackend;
* @todo Rework Hook:: methods to dynamic to remove the separated process annotation * @todo Rework Hook:: methods to dynamic to remove the separated process annotation
* *
* @runTestsInSeparateProcesses * @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/ */
class StorageManagerTest extends DatabaseTest class StorageManagerTest extends DatabaseTest
{ {