AppLocator.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2016, ownCloud, Inc.
  5. *
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OC\IntegrityCheck\Helpers;
  24. /**
  25. * Class AppLocator provides a non-static helper for OC_App::getPath($appId)
  26. * it is not possible to use IAppManager at this point as IAppManager has a
  27. * dependency on a running ownCloud.
  28. *
  29. * @package OC\IntegrityCheck\Helpers
  30. */
  31. class AppLocator {
  32. /**
  33. * Provides \OC_App::getAppPath($appId)
  34. *
  35. * @param string $appId
  36. * @return string
  37. * @throws \Exception If the app cannot be found
  38. */
  39. public function getAppPath(string $appId): string {
  40. $path = \OC_App::getAppPath($appId);
  41. if($path === false) {
  42. throw new \Exception('App not found');
  43. }
  44. return $path;
  45. }
  46. /**
  47. * Providers \OC_App::getAllApps()
  48. *
  49. * @return array
  50. */
  51. public function getAllApps(): array {
  52. return \OC_App::getAllApps();
  53. }
  54. }