1
0
Fork 0
mirror of synced 2024-09-28 23:41:23 +12:00

chore: DI+CO improvements

This commit is contained in:
Binyamin Yawitz 2024-06-24 13:31:40 -04:00
parent 3ecd8ce189
commit 97cd5e4934
No known key found for this signature in database
4 changed files with 1734 additions and 1758 deletions

View file

@ -25,11 +25,16 @@ Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
* @var Registry $global
* @var Container $container
*/
$context = new Dependency();
$register = new Dependency();
$logError = new Dependency();
$queueForDeletes = new Dependency();
$queueForCertificates = new Dependency();
$context
->setName('context')
->setCallback(fn() => $container);
$register
->setName('register')
->setCallback(function () use (&$global): Registry {
@ -91,7 +96,7 @@ $logError
};
});
$container->set($context);
$container->set($logError);
$container->set($register);
$container->set($queueForDeletes);

File diff suppressed because it is too large Load diff

View file

@ -36,6 +36,7 @@ use Utopia\CLI\Console;
use Utopia\Config\Config;
use Utopia\Database\Adapter\MariaDB;
use Utopia\Database\Adapter\MySQL;
use Utopia\Database\Adapter\SQL;
use Utopia\Database\Database;
use Utopia\Database\Document;
use Utopia\Database\Helpers\ID;
@ -380,6 +381,21 @@ $global->set('promiseAdapter', function () {
return new Swoole();
});
$global->set('db', function () {
// This is usually for our workers or CLI commands scope
$dbHost = System::getEnv('_APP_DB_HOST', '');
$dbPort = System::getEnv('_APP_DB_PORT', '');
$dbUser = System::getEnv('_APP_DB_USER', '');
$dbPass = System::getEnv('_APP_DB_PASS', '');
$dbScheme = System::getEnv('_APP_DB_SCHEMA', '');
return new PDO(
"mysql:host={$dbHost};port={$dbPort};dbname={$dbScheme};charset=utf8mb4",
$dbUser,
$dbPass,
SQL::getPDOAttributes()
);
});
$log = new Dependency();
$mode = new Dependency();

8
composer.lock generated
View file

@ -1626,12 +1626,12 @@
"source": {
"type": "git",
"url": "https://github.com/utopia-php/cli.git",
"reference": "bedbca08f451dc96f0321014e805a1f46f76f6b9"
"reference": "d48b696891dee1e46df2491d192bb91cf4df8f94"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/cli/zipball/bedbca08f451dc96f0321014e805a1f46f76f6b9",
"reference": "bedbca08f451dc96f0321014e805a1f46f76f6b9",
"url": "https://api.github.com/repos/utopia-php/cli/zipball/d48b696891dee1e46df2491d192bb91cf4df8f94",
"reference": "d48b696891dee1e46df2491d192bb91cf4df8f94",
"shasum": ""
},
"require": {
@ -1669,7 +1669,7 @@
"issues": "https://github.com/utopia-php/cli/issues",
"source": "https://github.com/utopia-php/cli/tree/dev-coroutines"
},
"time": "2024-06-07T18:51:16+00:00"
"time": "2024-06-24T13:24:20+00:00"
},
{
"name": "utopia-php/config",