application.php 2.1 KB

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