1
0

MoveToTrashEvent.php 1001 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\Files_Trashbin\Events;
  7. use OCP\EventDispatcher\Event;
  8. use OCP\Files\Node;
  9. /**
  10. * Class MoveToTrashEvent
  11. *
  12. * Event to allow other apps to disable the trash bin for specific files
  13. *
  14. * @package OCA\Files_Trashbin\Events
  15. * @since 28.0.0 Dispatched as a typed event
  16. */
  17. class MoveToTrashEvent extends Event {
  18. /** @var bool */
  19. private $moveToTrashBin;
  20. public function __construct(
  21. private Node $node,
  22. ) {
  23. $this->moveToTrashBin = true;
  24. }
  25. /**
  26. * get Node which will be deleted
  27. *
  28. * @return Node
  29. */
  30. public function getNode() {
  31. return $this->node;
  32. }
  33. /**
  34. * disable trash bin for this operation
  35. */
  36. public function disableTrashBin() {
  37. $this->moveToTrashBin = false;
  38. }
  39. /**
  40. * should the file be moved to the trash bin?
  41. *
  42. * @return bool
  43. */
  44. public function shouldMoveToTrashBin() {
  45. return $this->moveToTrashBin;
  46. }
  47. }