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.

96 lines
3.4 KiB

  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Arthur Schiwon <blizzz@arthur-schiwon.de>
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  9. * @author Roeland Jago Douma <roeland@famdouma.nl>
  10. *
  11. * @license GNU AGPL version 3 or any later version
  12. *
  13. * This program is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License as
  15. * published by the Free Software Foundation, either version 3 of the
  16. * License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  25. *
  26. */
  27. namespace OCA\Comments\AppInfo;
  28. use OCA\Comments\Capabilities;
  29. use OCA\Comments\Controller\Notifications;
  30. use OCA\Comments\EventHandler;
  31. use OCA\Comments\JSSettingsHelper;
  32. use OCA\Comments\Listener\CommentsEntityEventListener;
  33. use OCA\Comments\Listener\LoadAdditionalScripts;
  34. use OCA\Comments\Listener\LoadSidebarScripts;
  35. use OCA\Comments\Notification\Notifier;
  36. use OCA\Comments\Search\LegacyProvider;
  37. use OCA\Comments\Search\Provider;
  38. use OCA\Files\Event\LoadAdditionalScriptsEvent;
  39. use OCA\Files\Event\LoadSidebar;
  40. use OCP\AppFramework\App;
  41. use OCP\AppFramework\Bootstrap\IBootContext;
  42. use OCP\AppFramework\Bootstrap\IBootstrap;
  43. use OCP\AppFramework\Bootstrap\IRegistrationContext;
  44. use OCP\Comments\CommentsEntityEvent;
  45. use OCP\IServerContainer;
  46. use OCP\Util;
  47. class Application extends App implements IBootstrap {
  48. public const APP_ID = 'comments';
  49. public function __construct(array $urlParams = []) {
  50. parent::__construct(self::APP_ID, $urlParams);
  51. }
  52. public function register(IRegistrationContext $context): void {
  53. $context->registerCapability(Capabilities::class);
  54. $context->registerServiceAlias('NotificationsController', Notifications::class);
  55. $context->registerEventListener(
  56. LoadAdditionalScriptsEvent::class,
  57. LoadAdditionalScripts::class
  58. );
  59. $context->registerEventListener(
  60. LoadSidebar::class,
  61. LoadSidebarScripts::class
  62. );
  63. $context->registerEventListener(
  64. CommentsEntityEvent::EVENT_ENTITY,
  65. CommentsEntityEventListener::class
  66. );
  67. $context->registerSearchProvider(Provider::class);
  68. }
  69. public function boot(IBootContext $context): void {
  70. $this->registerNotifier($context->getServerContainer());
  71. $this->registerCommentsEventHandler($context->getServerContainer());
  72. $jsSettingsHelper = new JSSettingsHelper($context->getServerContainer());
  73. Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
  74. $context->getServerContainer()->getSearch()->registerProvider(LegacyProvider::class, ['apps' => ['files']]);
  75. }
  76. protected function registerNotifier(IServerContainer $container) {
  77. $container->getNotificationManager()->registerNotifierService(Notifier::class);
  78. }
  79. protected function registerCommentsEventHandler(IServerContainer $container) {
  80. $container->getCommentsManager()->registerEventHandler(function () {
  81. return $this->getContainer()->query(EventHandler::class);
  82. });
  83. }
  84. }