2015-02-17 10:49:14 -05:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2015-02-17 10:49:14 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-02-17 10:49:14 -05:00
|
|
|
*/
|
|
|
|
|
namespace OC\Command;
|
|
|
|
|
|
2024-02-08 05:52:40 -05:00
|
|
|
use OCP\BackgroundJob\QueuedJob;
|
2015-02-17 10:49:14 -05:00
|
|
|
use OCP\Command\ICommand;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Wrap a command in the background job interface
|
|
|
|
|
*/
|
|
|
|
|
class CommandJob extends QueuedJob {
|
2023-09-30 16:46:32 -04:00
|
|
|
protected function run($argument) {
|
|
|
|
|
$command = unserialize($argument);
|
2015-02-17 10:49:14 -05:00
|
|
|
if ($command instanceof ICommand) {
|
|
|
|
|
$command->handle();
|
|
|
|
|
} else {
|
|
|
|
|
throw new \InvalidArgumentException('Invalid serialized command');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|