Application.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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\Controller\ApiController;
  30. use OCP\AppFramework\App;
  31. use \OCA\Files\Service\TagService;
  32. use \OCP\IContainer;
  33. use OCA\Files\Controller\ViewController;
  34. use OCA\Files\Capabilities;
  35. class Application extends App {
  36. public function __construct(array $urlParams=array()) {
  37. parent::__construct('files', $urlParams);
  38. $container = $this->getContainer();
  39. $server = $container->getServer();
  40. /**
  41. * Controllers
  42. */
  43. $container->registerService('APIController', function (IContainer $c) use ($server) {
  44. return new ApiController(
  45. $c->query('AppName'),
  46. $c->query('Request'),
  47. $server->getUserSession(),
  48. $c->query('TagService'),
  49. $server->getPreviewManager(),
  50. $server->getShareManager(),
  51. $server->getConfig(),
  52. $server->getUserFolder()
  53. );
  54. });
  55. $container->registerService('ViewController', function (IContainer $c) use ($server) {
  56. return new ViewController(
  57. $c->query('AppName'),
  58. $c->query('Request'),
  59. $server->getURLGenerator(),
  60. $c->query('L10N'),
  61. $server->getConfig(),
  62. $server->getEventDispatcher(),
  63. $server->getUserSession(),
  64. $server->getAppManager(),
  65. $server->getRootFolder(),
  66. $c->query(Helper::class)
  67. );
  68. });
  69. /**
  70. * Core
  71. */
  72. $container->registerService('L10N', function(IContainer $c) {
  73. return $c->query('ServerContainer')->getL10N($c->query('AppName'));
  74. });
  75. /**
  76. * Services
  77. */
  78. $container->registerService('Tagger', function(IContainer $c) {
  79. return $c->query('ServerContainer')->getTagManager()->load('files');
  80. });
  81. $container->registerService('TagService', function(IContainer $c) use ($server) {
  82. $homeFolder = $c->query('ServerContainer')->getUserFolder();
  83. return new TagService(
  84. $c->query('ServerContainer')->getUserSession(),
  85. $c->query('ServerContainer')->getActivityManager(),
  86. $c->query('Tagger'),
  87. $homeFolder,
  88. $server->getEventDispatcher()
  89. );
  90. });
  91. /*
  92. * Register capabilities
  93. */
  94. $container->registerCapability(Capabilities::class);
  95. }
  96. }