MoveToTrashEvent.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\Files_Trashbin\Events;
  26. use OCP\EventDispatcher\Event;
  27. use OCP\Files\Node;
  28. /**
  29. * Class MoveToTrashEvent
  30. *
  31. * Event to allow other apps to disable the trash bin for specific files
  32. *
  33. * @package OCA\Files_Trashbin\Events
  34. * @since 28.0.0 Dispatched as a typed event
  35. */
  36. class MoveToTrashEvent extends Event {
  37. /** @var bool */
  38. private $moveToTrashBin;
  39. /** @var Node */
  40. private $node;
  41. public function __construct(Node $node) {
  42. $this->moveToTrashBin = true;
  43. $this->node = $node;
  44. }
  45. /**
  46. * get Node which will be deleted
  47. *
  48. * @return Node
  49. */
  50. public function getNode() {
  51. return $this->node;
  52. }
  53. /**
  54. * disable trash bin for this operation
  55. */
  56. public function disableTrashBin() {
  57. $this->moveToTrashBin = false;
  58. }
  59. /**
  60. * should the file be moved to the trash bin?
  61. *
  62. * @return bool
  63. */
  64. public function shouldMoveToTrashBin() {
  65. return $this->moveToTrashBin;
  66. }
  67. }