1
0

CommandJob.php 586 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\Command;
  8. use OCP\BackgroundJob\QueuedJob;
  9. use OCP\Command\ICommand;
  10. /**
  11. * Wrap a command in the background job interface
  12. */
  13. class CommandJob extends QueuedJob {
  14. protected function run($argument) {
  15. $command = unserialize($argument);
  16. if ($command instanceof ICommand) {
  17. $command->handle();
  18. } else {
  19. throw new \InvalidArgumentException('Invalid serialized command');
  20. }
  21. }
  22. }