diff --git a/lib/private/AppFramework/Bootstrap/RegistrationContext.php b/lib/private/AppFramework/Bootstrap/RegistrationContext.php index 6a9073b576bcc..e1abd81d80aad 100644 --- a/lib/private/AppFramework/Bootstrap/RegistrationContext.php +++ b/lib/private/AppFramework/Bootstrap/RegistrationContext.php @@ -32,6 +32,7 @@ use Closure; use function array_shift; use OC\Support\CrashReport\Registry; +use OCP\UserMigration\IMigrationOperation; use OCP\AppFramework\App; use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Middleware; @@ -65,6 +66,9 @@ class RegistrationContext { /** @var ServiceRegistration[] */ private $profileLinkActions = []; + /** @var ServiceRegistration[] */ + private $migrationOperations = []; + /** @var ServiceFactoryRegistration[] */ private $services = []; @@ -259,6 +263,13 @@ public function registerProfileLinkAction(string $actionClass): void { $actionClass ); } + + public function registerMigrationOperation(string $operationClass): void { + $this->context->registerMigrationOperation( + $this->appId, + $operationClass + ); + } }; } @@ -349,6 +360,13 @@ public function registerProfileLinkAction(string $appId, string $actionClass): v $this->profileLinkActions[] = new ServiceRegistration($appId, $actionClass); } + /** + * @psalm-param class-string $operationClass + */ + public function registerMigrationOperation(string $appId, string $operationClass): void { + $this->migrationOperations[] = new ServiceRegistration($appId, $operationClass); + } + /** * @param App[] $apps */ @@ -600,4 +618,11 @@ public function getCalendarProviders(): array { public function getProfileLinkActions(): array { return $this->profileLinkActions; } + + /** + * @return ServiceRegistration[] + */ + public function getMigrationOperations(): array { + return $this->migrationOperations; + } } diff --git a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php index be936540aee14..57774ff820b9e 100644 --- a/lib/public/AppFramework/Bootstrap/IRegistrationContext.php +++ b/lib/public/AppFramework/Bootstrap/IRegistrationContext.php @@ -264,4 +264,15 @@ public function registerCalendarProvider(string $class): void; * @since 23.0.0 */ public function registerProfileLinkAction(string $actionClass): void; + + /** + * Register an implementation of \OCP\UserMigration\IMigrationOperation that + * will handle the implementation of a migration operation + * + * @param string $operationClass + * @psalm-param class-string<\OCP\UserMigration\IMigrationOperation> $operationClass + * @return void + * @since 24.0.0 + */ + public function registerMigrationOperation(string $operationClass): void; } diff --git a/lib/public/UserMigration/IMigrationOperation.php b/lib/public/UserMigration/IMigrationOperation.php new file mode 100644 index 0000000000000..f3a434681e2d3 --- /dev/null +++ b/lib/public/UserMigration/IMigrationOperation.php @@ -0,0 +1,59 @@ + + * + * @author Christopher Ng + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCP\UserMigration; + +use OCP\IUser; +use Symfony\Component\Console\Output\OutputInterface; + +interface IMigrationOperation { + + /** + * Export user data + * + * @since 24.0.0 + */ + public function export( + string $appId, + IUser $user, + // TODO move to OCP + IExportDestination $exportDestination, + OutputInterface $output + ): void; + + /** + * Import user data + * + * @since 24.0.0 + */ + public function import( + string $appId, + IUser $user, + // TODO move to OCP + IImportSource $importSource, + OutputInterface $output + ): void; +}