UpdateGroups.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  7. * @author Bart Visscher <bartv@thisnet.nl>
  8. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  9. * @author Côme Chilliet <come.chilliet@nextcloud.com>
  10. * @author Joas Schilling <coding@schilljs.com>
  11. * @author Lukas Reschke <lukas@statuscode.ch>
  12. * @author Morris Jobke <hey@morrisjobke.de>
  13. * @author Robin Appelman <robin@icewind.nl>
  14. * @author Robin McCorkell <robin@mccorkell.me.uk>
  15. *
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. namespace OCA\User_LDAP\Jobs;
  32. use OCA\User_LDAP\Service\UpdateGroupsService;
  33. use OCP\AppFramework\Utility\ITimeFactory;
  34. use OCP\BackgroundJob\TimedJob;
  35. use OCP\DB\Exception;
  36. use OCP\IConfig;
  37. use Psr\Log\LoggerInterface;
  38. class UpdateGroups extends TimedJob {
  39. public function __construct(
  40. private UpdateGroupsService $service,
  41. private LoggerInterface $logger,
  42. IConfig $config,
  43. ITimeFactory $timeFactory,
  44. ) {
  45. parent::__construct($timeFactory);
  46. $this->interval = (int)$config->getAppValue('user_ldap', 'bgjRefreshInterval', '3600');
  47. }
  48. /**
  49. * @param mixed $argument
  50. * @throws Exception
  51. */
  52. public function run($argument): void {
  53. $this->logger->debug('Run background job "updateGroups"');
  54. $this->service->updateGroups();
  55. }
  56. }