Allow overriding realtime instance
This commit is contained in:
parent
6f55068838
commit
c4b742ac0d
2 changed files with 15 additions and 4 deletions
|
@ -40,7 +40,7 @@ require_once __DIR__ . '/init.php';
|
|||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
|
||||
// Allows overriding
|
||||
if (!function_exists("getConsoleDB")) {
|
||||
if (!function_exists('getConsoleDB')) {
|
||||
function getConsoleDB(): Database
|
||||
{
|
||||
global $register;
|
||||
|
@ -66,7 +66,7 @@ if (!function_exists("getConsoleDB")) {
|
|||
}
|
||||
|
||||
// Allows overriding
|
||||
if (!function_exists("getProjectDB")) {
|
||||
if (!function_exists('getProjectDB')) {
|
||||
function getProjectDB(Document $project): Database
|
||||
{
|
||||
global $register;
|
||||
|
@ -113,7 +113,7 @@ if (!function_exists("getProjectDB")) {
|
|||
}
|
||||
|
||||
// Allows overriding
|
||||
if (!function_exists("getCache")) {
|
||||
if (!function_exists('getCache')) {
|
||||
function getCache(): Cache
|
||||
{
|
||||
global $register;
|
||||
|
@ -135,7 +135,14 @@ if (!function_exists("getCache")) {
|
|||
}
|
||||
}
|
||||
|
||||
$realtime = new Realtime();
|
||||
if (!function_exists('getRealtime')) {
|
||||
function getRealtime(): Realtime
|
||||
{
|
||||
return new Realtime();
|
||||
}
|
||||
}
|
||||
|
||||
$realtime = getRealtime();
|
||||
|
||||
/**
|
||||
* Table for statistics across all workers.
|
||||
|
|
|
@ -243,7 +243,11 @@ class Realtime extends Adapter
|
|||
* @param string $event
|
||||
* @param Document $payload
|
||||
* @param Document|null $project
|
||||
* @param Document|null $database
|
||||
* @param Document|null $collection
|
||||
* @param Document|null $bucket
|
||||
* @return array
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function fromPayload(string $event, Document $payload, Document $project = null, Document $database = null, Document $collection = null, Document $bucket = null): array
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue