2017-09-15 12:14:08 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2024-06-02 15:26:54 +02:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-09-15 12:14:08 +02:00
|
|
|
*/
|
|
|
|
namespace OCA\Files_Versions\Events;
|
|
|
|
|
2019-10-16 12:36:03 +02:00
|
|
|
use OCP\EventDispatcher\Event;
|
2019-11-22 20:52:10 +01:00
|
|
|
use OCP\Files\Node;
|
2017-09-15 12:14:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2024-10-18 12:04:22 +02:00
|
|
|
public function __construct(
|
|
|
|
private Node $node,
|
|
|
|
) {
|
2017-09-15 12:14:08 +02:00
|
|
|
$this->createVersion = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* get Node of the file which should be versioned
|
|
|
|
*
|
|
|
|
* @return Node
|
|
|
|
*/
|
2021-07-14 14:48:23 +02:00
|
|
|
public function getNode(): Node {
|
2017-09-15 12:14:08 +02:00
|
|
|
return $this->node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* disable versions for this file
|
|
|
|
*/
|
2021-07-14 14:48:23 +02:00
|
|
|
public function disableVersions(): void {
|
2017-09-15 12:14:08 +02:00
|
|
|
$this->createVersion = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* should a version be created for this file?
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2021-07-14 14:48:23 +02:00
|
|
|
public function shouldCreateVersion(): bool {
|
2017-09-15 12:14:08 +02:00
|
|
|
return $this->createVersion;
|
|
|
|
}
|
|
|
|
}
|