1
0

MoveToTrashEvent.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. /** @var Node */
  21. private $node;
  22. public function __construct(Node $node) {
  23. $this->moveToTrashBin = true;
  24. $this->node = $node;
  25. }
  26. /**
  27. * get Node which will be deleted
  28. *
  29. * @return Node
  30. */
  31. public function getNode() {
  32. return $this->node;
  33. }
  34. /**
  35. * disable trash bin for this operation
  36. */
  37. public function disableTrashBin() {
  38. $this->moveToTrashBin = false;
  39. }
  40. /**
  41. * should the file be moved to the trash bin?
  42. *
  43. * @return bool
  44. */
  45. public function shouldMoveToTrashBin() {
  46. return $this->moveToTrashBin;
  47. }
  48. }