Rework project creation
This commit is contained in:
parent
a89b73d20b
commit
abb1007385
1 changed files with 4 additions and 8 deletions
|
@ -172,14 +172,8 @@ App::post('/v1/projects')
|
||||||
throw new Exception(Exception::PROJECT_ALREADY_EXISTS);
|
throw new Exception(Exception::PROJECT_ALREADY_EXISTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Useful for ZDT to mirror the project to destination
|
$dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache);
|
||||||
$dbForProject = $hooks->trigger('getProxyProjectDatabase', [ $project, $pools, $cache ]);
|
$dbForProject->setNamespace("_{$project->getInternalId()}");
|
||||||
|
|
||||||
if (empty($dbForProject)) {
|
|
||||||
$dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache);
|
|
||||||
$dbForProject->setNamespace("_{$project->getInternalId()}");
|
|
||||||
}
|
|
||||||
|
|
||||||
$dbForProject->create();
|
$dbForProject->create();
|
||||||
|
|
||||||
$audit = new Audit($dbForProject);
|
$audit = new Audit($dbForProject);
|
||||||
|
@ -225,6 +219,8 @@ App::post('/v1/projects')
|
||||||
$dbForProject->createCollection($key, $attributes, $indexes);
|
$dbForProject->createCollection($key, $attributes, $indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$hooks->trigger('afterProjectCreation', [ $project, $pools, $cache ]);
|
||||||
|
|
||||||
$response
|
$response
|
||||||
->setStatusCode(Response::STATUS_CODE_CREATED)
|
->setStatusCode(Response::STATUS_CODE_CREATED)
|
||||||
->dynamic($project, Response::MODEL_PROJECT);
|
->dynamic($project, Response::MODEL_PROJECT);
|
||||||
|
|
Loading…
Reference in a new issue