Factory.php 850 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Files\AppData;
  8. use OC\SystemConfig;
  9. use OCP\Files\AppData\IAppDataFactory;
  10. use OCP\Files\IAppData;
  11. use OCP\Files\IRootFolder;
  12. class Factory implements IAppDataFactory {
  13. private IRootFolder $rootFolder;
  14. private SystemConfig $config;
  15. /** @var array<string, IAppData> */
  16. private array $folders = [];
  17. public function __construct(IRootFolder $rootFolder,
  18. SystemConfig $systemConfig) {
  19. $this->rootFolder = $rootFolder;
  20. $this->config = $systemConfig;
  21. }
  22. public function get(string $appId): IAppData {
  23. if (!isset($this->folders[$appId])) {
  24. $this->folders[$appId] = new AppData($this->rootFolder, $this->config, $appId);
  25. }
  26. return $this->folders[$appId];
  27. }
  28. }