application.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * @author Roeland Jago Douma <rullzer@owncloud.com>
  4. * @author Tobias Kaminsky <tobias@kaminsky.me>
  5. * @author Vincent Petry <pvince81@owncloud.com>
  6. *
  7. * @copyright Copyright (c) 2016, ownCloud, Inc.
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\Files\AppInfo;
  24. use OCA\Files\Controller\ApiController;
  25. use OCP\AppFramework\App;
  26. use \OCA\Files\Service\TagService;
  27. use \OCP\IContainer;
  28. class Application extends App {
  29. public function __construct(array $urlParams=array()) {
  30. parent::__construct('files', $urlParams);
  31. $container = $this->getContainer();
  32. $server = $container->getServer();
  33. /**
  34. * Controllers
  35. */
  36. $container->registerService('APIController', function (IContainer $c) use ($server) {
  37. return new ApiController(
  38. $c->query('AppName'),
  39. $c->query('Request'),
  40. $c->query('TagService'),
  41. $server->getPreviewManager()
  42. );
  43. });
  44. /**
  45. * Core
  46. */
  47. $container->registerService('L10N', function(IContainer $c) {
  48. return $c->query('ServerContainer')->getL10N($c->query('AppName'));
  49. });
  50. /**
  51. * Services
  52. */
  53. $container->registerService('Tagger', function(IContainer $c) {
  54. return $c->query('ServerContainer')->getTagManager()->load('files');
  55. });
  56. $container->registerService('TagService', function(IContainer $c) {
  57. $homeFolder = $c->query('ServerContainer')->getUserFolder();
  58. return new TagService(
  59. $c->query('ServerContainer')->getUserSession(),
  60. $c->query('Tagger'),
  61. $homeFolder
  62. );
  63. });
  64. /*
  65. * Register capabilities
  66. */
  67. $container->registerCapability('OCA\Files\Capabilities');
  68. }
  69. }