1
0
Fork 0
mirror of synced 2024-09-15 00:48:25 +12:00

Add getProxyProjectDatabase hook

This commit is contained in:
Matej Bačo 2024-02-07 10:16:17 +01:00
parent a7e95588c6
commit 939aec866e

View file

@ -172,9 +172,14 @@ App::post('/v1/projects')
throw new Exception(Exception::PROJECT_ALREADY_EXISTS); throw new Exception(Exception::PROJECT_ALREADY_EXISTS);
} }
$dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache); // Useful for ZDT to mirror the project to destination
$dbForProject->setNamespace("_{$project->getInternalId()}"); $dbForProject = $hooks->trigger('getProxyProjectDatabase', [ $project, $pools, $cache ]);
$dbForProject->create();
if(empty($dbForProject)) {
$dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache);
$dbForProject->setNamespace("_{$project->getInternalId()}");
$dbForProject->create();
}
$audit = new Audit($dbForProject); $audit = new Audit($dbForProject);
$audit->setup(); $audit->setup();
@ -219,8 +224,6 @@ App::post('/v1/projects')
$dbForProject->createCollection($key, $attributes, $indexes); $dbForProject->createCollection($key, $attributes, $indexes);
} }
$hooks->trigger('afterProjectCreated'); // Useful for ZDT to mirror the project to destination
$response $response
->setStatusCode(Response::STATUS_CODE_CREATED) ->setStatusCode(Response::STATUS_CODE_CREATED)
->dynamic($project, Response::MODEL_PROJECT); ->dynamic($project, Response::MODEL_PROJECT);