1
0

SetupManagerFactory.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2022 Robin Appelman <robin@icewind.nl>
  5. *
  6. * @license GNU AGPL version 3 or any later version
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OC\Files;
  23. use OCP\Diagnostics\IEventLogger;
  24. use OCP\EventDispatcher\IEventDispatcher;
  25. use OCP\Files\Config\IMountProviderCollection;
  26. use OCP\Files\Config\IUserMountCache;
  27. use OCP\Files\Mount\IMountManager;
  28. use OCP\ICacheFactory;
  29. use OCP\IConfig;
  30. use OCP\IUserManager;
  31. use OCP\IUserSession;
  32. use OCP\Lockdown\ILockdownManager;
  33. use Psr\Log\LoggerInterface;
  34. class SetupManagerFactory {
  35. private IEventLogger $eventLogger;
  36. private IMountProviderCollection $mountProviderCollection;
  37. private IUserManager $userManager;
  38. private IEventDispatcher $eventDispatcher;
  39. private IUserMountCache $userMountCache;
  40. private ILockdownManager $lockdownManager;
  41. private IUserSession $userSession;
  42. private ?SetupManager $setupManager;
  43. private ICacheFactory $cacheFactory;
  44. private LoggerInterface $logger;
  45. private IConfig $config;
  46. public function __construct(
  47. IEventLogger $eventLogger,
  48. IMountProviderCollection $mountProviderCollection,
  49. IUserManager $userManager,
  50. IEventDispatcher $eventDispatcher,
  51. IUserMountCache $userMountCache,
  52. ILockdownManager $lockdownManager,
  53. IUserSession $userSession,
  54. ICacheFactory $cacheFactory,
  55. LoggerInterface $logger,
  56. IConfig $config
  57. ) {
  58. $this->eventLogger = $eventLogger;
  59. $this->mountProviderCollection = $mountProviderCollection;
  60. $this->userManager = $userManager;
  61. $this->eventDispatcher = $eventDispatcher;
  62. $this->userMountCache = $userMountCache;
  63. $this->lockdownManager = $lockdownManager;
  64. $this->userSession = $userSession;
  65. $this->cacheFactory = $cacheFactory;
  66. $this->logger = $logger;
  67. $this->config = $config;
  68. $this->setupManager = null;
  69. }
  70. public function create(IMountManager $mountManager): SetupManager {
  71. if (!$this->setupManager) {
  72. $this->setupManager = new SetupManager(
  73. $this->eventLogger,
  74. $this->mountProviderCollection,
  75. $mountManager,
  76. $this->userManager,
  77. $this->eventDispatcher,
  78. $this->userMountCache,
  79. $this->lockdownManager,
  80. $this->userSession,
  81. $this->cacheFactory,
  82. $this->logger,
  83. $this->config
  84. );
  85. }
  86. return $this->setupManager;
  87. }
  88. }