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);
|
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||||
|
|
||||||
// Allows overriding
|
// Allows overriding
|
||||||
if (!function_exists("getConsoleDB")) {
|
if (!function_exists('getConsoleDB')) {
|
||||||
function getConsoleDB(): Database
|
function getConsoleDB(): Database
|
||||||
{
|
{
|
||||||
global $register;
|
global $register;
|
||||||
|
@ -66,7 +66,7 @@ if (!function_exists("getConsoleDB")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows overriding
|
// Allows overriding
|
||||||
if (!function_exists("getProjectDB")) {
|
if (!function_exists('getProjectDB')) {
|
||||||
function getProjectDB(Document $project): Database
|
function getProjectDB(Document $project): Database
|
||||||
{
|
{
|
||||||
global $register;
|
global $register;
|
||||||
|
@ -113,7 +113,7 @@ if (!function_exists("getProjectDB")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allows overriding
|
// Allows overriding
|
||||||
if (!function_exists("getCache")) {
|
if (!function_exists('getCache')) {
|
||||||
function getCache(): Cache
|
function getCache(): Cache
|
||||||
{
|
{
|
||||||
global $register;
|
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.
|
* Table for statistics across all workers.
|
||||||
|
|
|
@ -243,7 +243,11 @@ class Realtime extends Adapter
|
||||||
* @param string $event
|
* @param string $event
|
||||||
* @param Document $payload
|
* @param Document $payload
|
||||||
* @param Document|null $project
|
* @param Document|null $project
|
||||||
|
* @param Document|null $database
|
||||||
|
* @param Document|null $collection
|
||||||
|
* @param Document|null $bucket
|
||||||
* @return array
|
* @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
|
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