1
0

AppLocator.php 838 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  6. * SPDX-License-Identifier: AGPL-3.0-only
  7. */
  8. namespace OC\IntegrityCheck\Helpers;
  9. /**
  10. * Class AppLocator provides a non-static helper for OC_App::getPath($appId)
  11. * it is not possible to use IAppManager at this point as IAppManager has a
  12. * dependency on a running Nextcloud.
  13. *
  14. * @package OC\IntegrityCheck\Helpers
  15. */
  16. class AppLocator {
  17. /**
  18. * Provides \OC_App::getAppPath($appId)
  19. *
  20. * @param string $appId
  21. * @return string
  22. * @throws \Exception If the app cannot be found
  23. */
  24. public function getAppPath(string $appId): string {
  25. $path = \OC_App::getAppPath($appId);
  26. if ($path === false) {
  27. throw new \Exception('App not found');
  28. }
  29. return $path;
  30. }
  31. }