You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Application.php 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud GmbH
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Morris Jobke <hey@morrisjobke.de>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. * @author Vincent Petry <vincent@nextcloud.com>
  9. *
  10. * @license AGPL-3.0
  11. *
  12. * This code is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License, version 3,
  14. * as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License, version 3,
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>
  23. *
  24. */
  25. namespace OCA\Testing\AppInfo;
  26. use OCA\Testing\AlternativeHomeUserBackend;
  27. use OCA\Testing\Listener\GetDeclarativeSettingsValueListener;
  28. use OCA\Testing\Listener\RegisterDeclarativeSettingsListener;
  29. use OCA\Testing\Listener\SetDeclarativeSettingsValueListener;
  30. use OCA\Testing\Provider\FakeText2ImageProvider;
  31. use OCA\Testing\Provider\FakeTextProcessingProvider;
  32. use OCA\Testing\Provider\FakeTextProcessingProviderSync;
  33. use OCA\Testing\Provider\FakeTranslationProvider;
  34. use OCA\Testing\Settings\DeclarativeSettingsForm;
  35. use OCP\AppFramework\App;
  36. use OCP\AppFramework\Bootstrap\IBootContext;
  37. use OCP\AppFramework\Bootstrap\IBootstrap;
  38. use OCP\AppFramework\Bootstrap\IRegistrationContext;
  39. use OCP\Settings\Events\DeclarativeSettingsGetValueEvent;
  40. use OCP\Settings\Events\DeclarativeSettingsRegisterFormEvent;
  41. use OCP\Settings\Events\DeclarativeSettingsSetValueEvent;
  42. class Application extends App implements IBootstrap {
  43. public function __construct(array $urlParams = []) {
  44. parent::__construct('testing', $urlParams);
  45. }
  46. public function register(IRegistrationContext $context): void {
  47. $context->registerTranslationProvider(FakeTranslationProvider::class);
  48. $context->registerTextProcessingProvider(FakeTextProcessingProvider::class);
  49. $context->registerTextProcessingProvider(FakeTextProcessingProviderSync::class);
  50. $context->registerTextToImageProvider(FakeText2ImageProvider::class);
  51. $context->registerDeclarativeSettings(DeclarativeSettingsForm::class);
  52. $context->registerEventListener(DeclarativeSettingsRegisterFormEvent::class, RegisterDeclarativeSettingsListener::class);
  53. $context->registerEventListener(DeclarativeSettingsGetValueEvent::class, GetDeclarativeSettingsValueListener::class);
  54. $context->registerEventListener(DeclarativeSettingsSetValueEvent::class, SetDeclarativeSettingsValueListener::class);
  55. }
  56. public function boot(IBootContext $context): void {
  57. $server = $context->getServerContainer();
  58. $config = $server->getConfig();
  59. if ($config->getAppValue('testing', 'enable_alt_user_backend', 'no') === 'yes') {
  60. $userManager = $server->getUserManager();
  61. // replace all user backends with this one
  62. $userManager->clearBackends();
  63. $userManager->registerBackend($context->getAppContainer()->get(AlternativeHomeUserBackend::class));
  64. }
  65. }
  66. }