apps.php 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. function loadDirectory($path): void {
  8. if (strpos($path, 'integration')) {
  9. return;
  10. }
  11. if (strpos($path, 'Integration')) {
  12. return;
  13. }
  14. if (! $dh = opendir($path)) {
  15. return;
  16. }
  17. while (($name = readdir($dh)) !== false) {
  18. if ($name[0] === '.') {
  19. continue;
  20. }
  21. $file = $path . '/' . $name;
  22. if (is_dir($file)) {
  23. loadDirectory($file);
  24. } elseif (str_ends_with($name, '.php')) {
  25. require_once $file;
  26. }
  27. }
  28. }
  29. function getSubclasses($parentClassName): array {
  30. $classes = [];
  31. foreach (get_declared_classes() as $className) {
  32. if (is_subclass_of($className, $parentClassName)) {
  33. $classes[] = $className;
  34. }
  35. }
  36. return $classes;
  37. }
  38. $apps = OC_App::getEnabledApps();
  39. foreach ($apps as $app) {
  40. $dir = OC_App::getAppPath($app);
  41. if (is_dir($dir . '/tests')) {
  42. loadDirectory($dir . '/tests');
  43. }
  44. }