ClosureJob.php 626 B

1234567891011121314151617181920212223
  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 Laravel\SerializableClosure\SerializableClosure as LaravelClosure;
  9. use OCP\BackgroundJob\QueuedJob;
  10. class ClosureJob extends QueuedJob {
  11. protected function run($argument) {
  12. $callable = unserialize($argument, [LaravelClosure::class]);
  13. $callable = $callable->getClosure();
  14. if (is_callable($callable)) {
  15. $callable();
  16. } else {
  17. throw new \InvalidArgumentException('Invalid serialized callable');
  18. }
  19. }
  20. }