From abb10073853071e28abc006a0f8e2ff0d920af1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 7 Feb 2024 12:04:46 +0100 Subject: [PATCH] Rework project creation --- app/controllers/api/projects.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 4613070611..4fb95cf175 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -172,14 +172,8 @@ App::post('/v1/projects') throw new Exception(Exception::PROJECT_ALREADY_EXISTS); } - // Useful for ZDT to mirror the project to destination - $dbForProject = $hooks->trigger('getProxyProjectDatabase', [ $project, $pools, $cache ]); - - if (empty($dbForProject)) { - $dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache); - $dbForProject->setNamespace("_{$project->getInternalId()}"); - } - + $dbForProject = new Database($pools->get($database)->pop()->getResource(), $cache); + $dbForProject->setNamespace("_{$project->getInternalId()}"); $dbForProject->create(); $audit = new Audit($dbForProject); @@ -225,6 +219,8 @@ App::post('/v1/projects') $dbForProject->createCollection($key, $attributes, $indexes); } + $hooks->trigger('afterProjectCreation', [ $project, $pools, $cache ]); + $response ->setStatusCode(Response::STATUS_CODE_CREATED) ->dynamic($project, Response::MODEL_PROJECT);