Application.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\TwoFactorBackupCodes\AppInfo;
  27. use OCA\TwoFactorBackupCodes\Event\CodesGenerated;
  28. use OCA\TwoFactorBackupCodes\Listener\ActivityPublisher;
  29. use OCA\TwoFactorBackupCodes\Listener\ClearNotifications;
  30. use OCA\TwoFactorBackupCodes\Listener\ProviderDisabled;
  31. use OCA\TwoFactorBackupCodes\Listener\ProviderEnabled;
  32. use OCA\TwoFactorBackupCodes\Listener\RegistryUpdater;
  33. use OCA\TwoFactorBackupCodes\Listener\UserDeleted;
  34. use OCA\TwoFactorBackupCodes\Notifications\Notifier;
  35. use OCA\TwoFactorBackupCodes\Provider\BackupCodesProvider;
  36. use OCP\AppFramework\App;
  37. use OCP\AppFramework\Bootstrap\IBootContext;
  38. use OCP\AppFramework\Bootstrap\IBootstrap;
  39. use OCP\AppFramework\Bootstrap\IRegistrationContext;
  40. use OCP\Authentication\TwoFactorAuth\IRegistry;
  41. use OCP\User\Events\UserDeletedEvent;
  42. class Application extends App implements IBootstrap {
  43. public const APP_ID = 'twofactor_backupcodes';
  44. public function __construct() {
  45. parent::__construct(self::APP_ID);
  46. }
  47. public function register(IRegistrationContext $context): void {
  48. $context->registerNotifierService(Notifier::class);
  49. $context->registerEventListener(CodesGenerated::class, ActivityPublisher::class);
  50. $context->registerEventListener(CodesGenerated::class, RegistryUpdater::class);
  51. $context->registerEventListener(CodesGenerated::class, ClearNotifications::class);
  52. $context->registerEventListener(IRegistry::EVENT_PROVIDER_ENABLED, ProviderEnabled::class);
  53. $context->registerEventListener(IRegistry::EVENT_PROVIDER_DISABLED, ProviderDisabled::class);
  54. $context->registerEventListener(UserDeletedEvent::class, UserDeleted::class);
  55. $context->registerTwoFactorProvider(BackupCodesProvider::class);
  56. }
  57. public function boot(IBootContext $context): void {
  58. }
  59. }