Application.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@owncloud.com>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Robin Appelman <robin@icewind.nl>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Tobias Kaminsky <tobias@kaminsky.me>
  10. * @author Vincent Petry <pvince81@owncloud.com>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  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, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCA\Files\AppInfo;
  28. use OCA\Files\Activity\Helper;
  29. use OCA\Files\Capabilities;
  30. use OCA\Files\Collaboration\Resources\Listener;
  31. use OCA\Files\Collaboration\Resources\ResourceProvider;
  32. use OCA\Files\Controller\ApiController;
  33. use OCA\Files\Controller\ViewController;
  34. use OCA\Files\Event\LoadAdditionalScriptsEvent;
  35. use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
  36. use OCA\Files\Notification\Notifier;
  37. use OCA\Files\Service\TagService;
  38. use OCP\AppFramework\App;
  39. use OCP\Collaboration\Resources\IManager;
  40. use OCP\EventDispatcher\IEventDispatcher;
  41. use OCP\IContainer;
  42. class Application extends App {
  43. public const APP_ID = 'files';
  44. public function __construct(array $urlParams=array()) {
  45. parent::__construct(self::APP_ID, $urlParams);
  46. $container = $this->getContainer();
  47. $server = $container->getServer();
  48. /**
  49. * Controllers
  50. */
  51. $container->registerService('APIController', function (IContainer $c) use ($server) {
  52. return new ApiController(
  53. $c->query('AppName'),
  54. $c->query('Request'),
  55. $server->getUserSession(),
  56. $c->query('TagService'),
  57. $server->getPreviewManager(),
  58. $server->getShareManager(),
  59. $server->getConfig(),
  60. $server->getUserFolder()
  61. );
  62. });
  63. /**
  64. * Services
  65. */
  66. $container->registerService('TagService', function(IContainer $c) use ($server) {
  67. $homeFolder = $c->query('ServerContainer')->getUserFolder();
  68. return new TagService(
  69. $c->query('ServerContainer')->getUserSession(),
  70. $c->query('ServerContainer')->getActivityManager(),
  71. $c->query('ServerContainer')->getTagManager()->load(self::APP_ID),
  72. $homeFolder,
  73. $server->getEventDispatcher()
  74. );
  75. });
  76. /*
  77. * Register capabilities
  78. */
  79. $container->registerCapability(Capabilities::class);
  80. /**
  81. * Register Collaboration ResourceProvider
  82. */
  83. /** @var IManager $resourceManager */
  84. $resourceManager = $container->query(IManager::class);
  85. $resourceManager->registerResourceProvider(ResourceProvider::class);
  86. Listener::register($server->getEventDispatcher());
  87. /** @var IEventDispatcher $dispatcher */
  88. $dispatcher = $container->query(IEventDispatcher::class);
  89. $dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
  90. /** @var \OCP\Notification\IManager $notifications */
  91. $notifications = $container->query(\OCP\Notification\IManager::class);
  92. $notifications->registerNotifierService(Notifier::class);
  93. }
  94. }