aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_versions/lib/Events/CreateVersionEvent.php
blob: 1399cdbb98801a6c75ac408e0e04854f486036e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
 * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\Files_Versions\Events;

use OCP\EventDispatcher\Event;
use OCP\Files\Node;

/**
 * Class CreateVersionEvent
 *
 * Event to allow other apps to disable versions for specific files
 *
 * @package OCA\Files_Versions
 */
class CreateVersionEvent extends Event {


	/** @var bool */
	private $createVersion;

	/**
	 * CreateVersionEvent constructor.
	 *
	 * @param Node $node
	 */
	public function __construct(
		private Node $node,
	) {
		$this->createVersion = true;
	}

	/**
	 * get Node of the file which should be versioned
	 *
	 * @return Node
	 */
	public function getNode(): Node {
		return $this->node;
	}

	/**
	 * disable versions for this file
	 */
	public function disableVersions(): void {
		$this->createVersion = false;
	}

	/**
	 * should a version be created for this file?
	 *
	 * @return bool
	 */
	public function shouldCreateVersion(): bool {
		return $this->createVersion;
	}
}