1
0

CreateVersionEvent.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. /**
  20. * CreateVersionEvent constructor.
  21. *
  22. * @param Node $node
  23. */
  24. public function __construct(
  25. private Node $node,
  26. ) {
  27. $this->createVersion = true;
  28. }
  29. /**
  30. * get Node of the file which should be versioned
  31. *
  32. * @return Node
  33. */
  34. public function getNode(): Node {
  35. return $this->node;
  36. }
  37. /**
  38. * disable versions for this file
  39. */
  40. public function disableVersions(): void {
  41. $this->createVersion = false;
  42. }
  43. /**
  44. * should a version be created for this file?
  45. *
  46. * @return bool
  47. */
  48. public function shouldCreateVersion(): bool {
  49. return $this->createVersion;
  50. }
  51. }