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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  9. * @author Julius Härtl <jus@bitgrid.net>
  10. * @author Morris Jobke <hey@morrisjobke.de>
  11. * @author Robin Appelman <robin@icewind.nl>
  12. * @author Roeland Jago Douma <roeland@famdouma.nl>
  13. * @author Tobias Kaminsky <tobias@kaminsky.me>
  14. * @author Vincent Petry <pvince81@owncloud.com>
  15. *
  16. * @license AGPL-3.0
  17. *
  18. * This code is free software: you can redistribute it and/or modify
  19. * it under the terms of the GNU Affero General Public License, version 3,
  20. * as published by the Free Software Foundation.
  21. *
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU Affero General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU Affero General Public License, version 3,
  28. * along with this program. If not, see <http://www.gnu.org/licenses/>
  29. *
  30. */
  31. namespace OCA\Files\AppInfo;
  32. use OCA\Files\Capabilities;
  33. use OCA\Files\Collaboration\Resources\Listener;
  34. use OCA\Files\Collaboration\Resources\ResourceProvider;
  35. use OCA\Files\Controller\ApiController;
  36. use OCA\Files\Event\LoadAdditionalScriptsEvent;
  37. use OCA\Files\Event\LoadSidebar;
  38. use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
  39. use OCA\Files\Listener\LoadSidebarListener;
  40. use OCA\Files\Notification\Notifier;
  41. use OCA\Files\Service\TagService;
  42. use OCP\AppFramework\App;
  43. use OCP\Collaboration\Resources\IProviderManager;
  44. use OCP\EventDispatcher\IEventDispatcher;
  45. use OCP\IContainer;
  46. class Application extends App {
  47. public const APP_ID = 'files';
  48. public function __construct(array $urlParams=array()) {
  49. parent::__construct(self::APP_ID, $urlParams);
  50. $container = $this->getContainer();
  51. $server = $container->getServer();
  52. /**
  53. * Controllers
  54. */
  55. $container->registerService('APIController', function (IContainer $c) use ($server) {
  56. return new ApiController(
  57. $c->query('AppName'),
  58. $c->query('Request'),
  59. $server->getUserSession(),
  60. $c->query('TagService'),
  61. $server->getPreviewManager(),
  62. $server->getShareManager(),
  63. $server->getConfig(),
  64. $server->getUserFolder()
  65. );
  66. });
  67. /**
  68. * Services
  69. */
  70. $container->registerService('TagService', function(IContainer $c) use ($server) {
  71. $homeFolder = $c->query('ServerContainer')->getUserFolder();
  72. return new TagService(
  73. $c->query('ServerContainer')->getUserSession(),
  74. $c->query('ServerContainer')->getActivityManager(),
  75. $c->query('ServerContainer')->getTagManager()->load(self::APP_ID),
  76. $homeFolder,
  77. $server->getEventDispatcher()
  78. );
  79. });
  80. /*
  81. * Register capabilities
  82. */
  83. $container->registerCapability(Capabilities::class);
  84. /**
  85. * Register Collaboration ResourceProvider
  86. */
  87. /** @var IProviderManager $providerManager */
  88. $providerManager = $container->query(IProviderManager::class);
  89. $providerManager->registerResourceProvider(ResourceProvider::class);
  90. Listener::register($server->getEventDispatcher());
  91. /** @var IEventDispatcher $dispatcher */
  92. $dispatcher = $container->query(IEventDispatcher::class);
  93. $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
  94. $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarListener::class);
  95. /** @var \OCP\Notification\IManager $notifications */
  96. $notifications = $container->query(\OCP\Notification\IManager::class);
  97. $notifications->registerNotifierService(Notifier::class);
  98. }
  99. }