BeforeNodeRestoredEvent.php 736 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\Files_Trashbin\Events;
  8. use Exception;
  9. use OCP\Files\Events\Node\AbstractNodesEvent;
  10. use OCP\Files\Node;
  11. /**
  12. * @since 28.0.0
  13. */
  14. class BeforeNodeRestoredEvent extends AbstractNodesEvent {
  15. public function __construct(
  16. Node $source,
  17. Node $target,
  18. private bool &$run,
  19. ) {
  20. parent::__construct($source, $target);
  21. }
  22. /**
  23. * @return never
  24. */
  25. public function abortOperation(?\Throwable $ex = null) {
  26. $this->stopPropagation();
  27. $this->run = false;
  28. if ($ex !== null) {
  29. throw $ex;
  30. } else {
  31. throw new Exception('Operation aborted');
  32. }
  33. }
  34. }