1
0

CreateVersionEvent.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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_Versions\Events;
  26. use OCP\EventDispatcher\Event;
  27. use OCP\Files\Node;
  28. /**
  29. * Class CreateVersionEvent
  30. *
  31. * Event to allow other apps to disable versions for specific files
  32. *
  33. * @package OCA\Files_Versions
  34. */
  35. class CreateVersionEvent extends Event {
  36. /** @var bool */
  37. private $createVersion;
  38. /** @var Node */
  39. private $node;
  40. /**
  41. * CreateVersionEvent constructor.
  42. *
  43. * @param Node $node
  44. */
  45. public function __construct(Node $node) {
  46. $this->createVersion = true;
  47. $this->node = $node;
  48. }
  49. /**
  50. * get Node of the file which should be versioned
  51. *
  52. * @return Node
  53. */
  54. public function getNode(): Node {
  55. return $this->node;
  56. }
  57. /**
  58. * disable versions for this file
  59. */
  60. public function disableVersions(): void {
  61. $this->createVersion = false;
  62. }
  63. /**
  64. * should a version be created for this file?
  65. *
  66. * @return bool
  67. */
  68. public function shouldCreateVersion(): bool {
  69. return $this->createVersion;
  70. }
  71. }