From ec71fb22de19a973eeb1e5b48d137e0abb913ed9 Mon Sep 17 00:00:00 2001 From: fogelito Date: Wed, 19 Jun 2024 11:45:07 +0300 Subject: [PATCH] Change processSource processDestination params --- src/Appwrite/Platform/Workers/Migrations.php | 35 ++++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Migrations.php b/src/Appwrite/Platform/Workers/Migrations.php index cdaefe41fc..19fd92e3fe 100644 --- a/src/Appwrite/Platform/Workers/Migrations.php +++ b/src/Appwrite/Platform/Workers/Migrations.php @@ -98,13 +98,15 @@ class Migrations extends Action } /** - * @param string $source - * @param array $credentials + * @param Document $migration * @return Source * @throws Exception */ - protected function processSource(string $source, array $credentials): Source + protected function processSource(Document $migration): Source { + $source = $migration->getAttribute('source'); + $credentials = $migration->getAttribute('credentials'); + return match ($source) { Firebase::getName() => new Firebase( json_decode($credentials['serviceAccount'], true), @@ -137,13 +139,15 @@ class Migrations extends Action } /** - * @param string $destination + * @param Document $migration * @param array $credentials * @return Destination * @throws Exception */ - protected function processDestination(string $destination, array $credentials): Destination + protected function processDestination(Document $migration, array $credentials): Destination { + $destination = $migration->getAttribute('destination'); + return match ($destination) { DestinationAppwrite::getName() => new DestinationAppwrite( $credentials['projectId'], @@ -284,19 +288,30 @@ class Migrations extends Action $log->addTag('type', $migrationDocument->getAttribute('source')); - $source = $this->processSource( - $migrationDocument->getAttribute('source'), - $migrationDocument->getAttribute('credentials') - ); + $source = $this->processSource($migrationDocument); $destination = $this->processDestination( - $migrationDocument->getAttribute('destination'), + $migrationDocument, [ 'projectId' => $projectDocument->getId(), 'endpoint' => 'http://appwrite/v1', 'apiKey' => $tempAPIKey['secret'] ] ); +// +// $source = $this->processSource( +// $migrationDocument->getAttribute('source'), +// $migrationDocument->getAttribute('credentials') +// ); +// +// $destination = $this->processDestination( +// $migrationDocument->getAttribute('destination'), +// [ +// 'projectId' => $projectDocument->getId(), +// 'endpoint' => 'http://appwrite/v1', +// 'apiKey' => $tempAPIKey['secret'] +// ] +// ); $source->report();