CleanupService.php 880 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCA\DAV\Upload;
  8. use OCA\DAV\BackgroundJob\UploadCleanup;
  9. use OCP\BackgroundJob\IJobList;
  10. use OCP\IUserSession;
  11. class CleanupService {
  12. /** @var IUserSession */
  13. private $userSession;
  14. /** @var IJobList */
  15. private $jobList;
  16. public function __construct(IUserSession $userSession, IJobList $jobList) {
  17. $this->userSession = $userSession;
  18. $this->jobList = $jobList;
  19. }
  20. public function addJob(string $folder) {
  21. $this->jobList->add(UploadCleanup::class, ['uid' => $this->userSession->getUser()->getUID(), 'folder' => $folder]);
  22. }
  23. public function removeJob(string $folder) {
  24. $this->jobList->remove(UploadCleanup::class, ['uid' => $this->userSession->getUser()->getUID(), 'folder' => $folder]);
  25. }
  26. }