Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/private/AppFramework/Bootstrap/RegistrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -65,6 +66,9 @@ class RegistrationContext {
/** @var ServiceRegistration<ILinkAction>[] */
private $profileLinkActions = [];

/** @var ServiceRegistration<IMigrationOperation>[] */
private $migrationOperations = [];

/** @var ServiceFactoryRegistration[] */
private $services = [];

Expand Down Expand Up @@ -259,6 +263,13 @@ public function registerProfileLinkAction(string $actionClass): void {
$actionClass
);
}

public function registerMigrationOperation(string $operationClass): void {
$this->context->registerMigrationOperation(
$this->appId,
$operationClass
);
}
};
}

Expand Down Expand Up @@ -349,6 +360,13 @@ public function registerProfileLinkAction(string $appId, string $actionClass): v
$this->profileLinkActions[] = new ServiceRegistration($appId, $actionClass);
}

/**
* @psalm-param class-string<IMigrationOperation> $operationClass
*/
public function registerMigrationOperation(string $appId, string $operationClass): void {
$this->migrationOperations[] = new ServiceRegistration($appId, $operationClass);
}

/**
* @param App[] $apps
*/
Expand Down Expand Up @@ -600,4 +618,11 @@ public function getCalendarProviders(): array {
public function getProfileLinkActions(): array {
return $this->profileLinkActions;
}

/**
* @return ServiceRegistration<IMigrationOperation>[]
*/
public function getMigrationOperations(): array {
return $this->migrationOperations;
}
}
11 changes: 11 additions & 0 deletions lib/public/AppFramework/Bootstrap/IRegistrationContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
59 changes: 59 additions & 0 deletions lib/public/UserMigration/IMigrationOperation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

declare(strict_types=1);

/**
* @copyright 2022 Christopher Ng <[email protected]>
*
* @author Christopher Ng <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

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;
}