BeforeNodeRestoredEvent.php 726 B

1234567891011121314151617181920212223242526272829303132333435
  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(Node $source, Node $target, private bool &$run) {
  16. parent::__construct($source, $target);
  17. }
  18. /**
  19. * @return never
  20. */
  21. public function abortOperation(?\Throwable $ex = null) {
  22. $this->stopPropagation();
  23. $this->run = false;
  24. if ($ex !== null) {
  25. throw $ex;
  26. } else {
  27. throw new Exception('Operation aborted');
  28. }
  29. }
  30. }