2017-09-14 07:59:09 -04:00
|
|
|
<?php
|
2025-06-30 09:04:05 -04:00
|
|
|
|
2017-09-14 07:59:09 -04:00
|
|
|
/**
|
2024-06-02 09:26:54 -04:00
|
|
|
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2017-09-14 07:59:09 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files_Trashbin\Events;
|
|
|
|
|
|
2019-10-16 06:36:03 -04:00
|
|
|
use OCP\EventDispatcher\Event;
|
2019-11-22 14:52:10 -05:00
|
|
|
use OCP\Files\Node;
|
2017-09-14 07:59:09 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class MoveToTrashEvent
|
|
|
|
|
*
|
|
|
|
|
* Event to allow other apps to disable the trash bin for specific files
|
|
|
|
|
*
|
|
|
|
|
* @package OCA\Files_Trashbin\Events
|
2023-07-07 05:27:29 -04:00
|
|
|
* @since 28.0.0 Dispatched as a typed event
|
2017-09-14 07:59:09 -04:00
|
|
|
*/
|
|
|
|
|
class MoveToTrashEvent extends Event {
|
|
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
|
private $moveToTrashBin;
|
|
|
|
|
|
2024-10-18 06:04:22 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private Node $node,
|
|
|
|
|
) {
|
2017-09-14 07:59:09 -04:00
|
|
|
$this->moveToTrashBin = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* get Node which will be deleted
|
|
|
|
|
*
|
|
|
|
|
* @return Node
|
|
|
|
|
*/
|
|
|
|
|
public function getNode() {
|
|
|
|
|
return $this->node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* disable trash bin for this operation
|
|
|
|
|
*/
|
|
|
|
|
public function disableTrashBin() {
|
|
|
|
|
$this->moveToTrashBin = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* should the file be moved to the trash bin?
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function shouldMoveToTrashBin() {
|
|
|
|
|
return $this->moveToTrashBin;
|
|
|
|
|
}
|
|
|
|
|
}
|