CreateVersionEvent.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_Versions\Events;
  7. use OCP\EventDispatcher\Event;
  8. use OCP\Files\Node;
  9. /**
  10. * Class CreateVersionEvent
  11. *
  12. * Event to allow other apps to disable versions for specific files
  13. *
  14. * @package OCA\Files_Versions
  15. */
  16. class CreateVersionEvent extends Event {
  17. /** @var bool */
  18. private $createVersion;
  19. /** @var Node */
  20. private $node;
  21. /**
  22. * CreateVersionEvent constructor.
  23. *
  24. * @param Node $node
  25. */
  26. public function __construct(Node $node) {
  27. $this->createVersion = true;
  28. $this->node = $node;
  29. }
  30. /**
  31. * get Node of the file which should be versioned
  32. *
  33. * @return Node
  34. */
  35. public function getNode(): Node {
  36. return $this->node;
  37. }
  38. /**
  39. * disable versions for this file
  40. */
  41. public function disableVersions(): void {
  42. $this->createVersion = false;
  43. }
  44. /**
  45. * should a version be created for this file?
  46. *
  47. * @return bool
  48. */
  49. public function shouldCreateVersion(): bool {
  50. return $this->createVersion;
  51. }
  52. }