Fixings
- Rename "facStorage" to "storageManager" - Fix indentation - Fix tests
This commit is contained in:
parent
bfae6766bf
commit
016cfcd846
|
@ -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)
|
||||
|
|
66
src/DI.php
66
src/DI.php
|
@ -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 */
|
||||
|
|
|
@ -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'] ?? '');
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue