1
0
Fork 0
mirror of synced 2024-08-31 09:51:33 +12:00

Add ZDT migration support to project creation

This commit is contained in:
Matej Bačo 2024-02-06 12:07:47 +01:00
parent 6fe725ff9d
commit d4afe22396
2 changed files with 12 additions and 3 deletions

View file

@ -4,6 +4,7 @@ use Appwrite\Auth\Auth;
use Appwrite\Event\Delete;
use Appwrite\Event\Validator\Event;
use Appwrite\Extend\Exception;
use Appwrite\Hooks\Hooks;
use Appwrite\Network\Validator\Email;
use Appwrite\Network\Validator\Origin;
use Appwrite\Template\Template;
@ -75,7 +76,8 @@ App::post('/v1/projects')
->inject('dbForConsole')
->inject('cache')
->inject('pools')
->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Cache $cache, Group $pools) {
->inject('hooks')
->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Cache $cache, Group $pools, Hooks $hooks) {
$team = $dbForConsole->getDocument('teams', $teamId);
@ -183,6 +185,12 @@ App::post('/v1/projects')
/** @var array $collections */
$collections = Config::getParam('collections', [])['projects'] ?? [];
// Allow Cloud overrides (useful for ZDT migration)
$collectiosOverride = $hooks->trigger('getProjectCollections');
if(!empty($collectiosOverride)) {
$collections = $collectiosOverride;
}
foreach ($collections as $key => $collection) {
if (($collection['$collection'] ?? '') !== Database::METADATA) {
continue;

View file

@ -16,11 +16,12 @@ class Hooks
/**
* @param mixed[] $params
* @return mixed
*/
public function trigger(string $name, array $params = [])
public function trigger(string $name, array $params = []): mixed
{
if (isset(self::$hooks[$name])) {
call_user_func_array(self::$hooks[$name], $params);
return call_user_func_array(self::$hooks[$name], $params);
}
}
}