application.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. /**
  3. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  4. * @author Lukas Reschke <lukas@owncloud.com>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Roeland Jago Douma <rullzer@owncloud.com>
  7. * @author Thomas Müller <thomas.mueller@tmit.eu>
  8. * @author Victor Dubiniuk <dubiniuk@owncloud.com>
  9. *
  10. * @copyright Copyright (c) 2015, ownCloud, Inc.
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OC\Core;
  27. use OC\AppFramework\Utility\SimpleContainer;
  28. use OC\AppFramework\Utility\TimeFactory;
  29. use \OCP\AppFramework\App;
  30. use OC\Core\LostPassword\Controller\LostController;
  31. use OC\Core\User\UserController;
  32. use OC\Core\Avatar\AvatarController;
  33. use \OCP\Util;
  34. /**
  35. * Class Application
  36. *
  37. * @package OC\Core
  38. */
  39. class Application extends App {
  40. /**
  41. * @param array $urlParams
  42. */
  43. public function __construct(array $urlParams=array()){
  44. parent::__construct('core', $urlParams);
  45. $container = $this->getContainer();
  46. /**
  47. * Controllers
  48. */
  49. $container->registerService('LostController', function(SimpleContainer $c) {
  50. return new LostController(
  51. $c->query('AppName'),
  52. $c->query('Request'),
  53. $c->query('URLGenerator'),
  54. $c->query('UserManager'),
  55. $c->query('Defaults'),
  56. $c->query('L10N'),
  57. $c->query('Config'),
  58. $c->query('SecureRandom'),
  59. $c->query('DefaultEmailAddress'),
  60. $c->query('IsEncryptionEnabled'),
  61. $c->query('Mailer'),
  62. $c->query('TimeFactory')
  63. );
  64. });
  65. $container->registerService('UserController', function(SimpleContainer $c) {
  66. return new UserController(
  67. $c->query('AppName'),
  68. $c->query('Request'),
  69. $c->query('UserManager'),
  70. $c->query('Defaults')
  71. );
  72. });
  73. $container->registerService('AvatarController', function(SimpleContainer $c) {
  74. return new AvatarController(
  75. $c->query('AppName'),
  76. $c->query('Request'),
  77. $c->query('AvatarManager'),
  78. $c->query('Cache'),
  79. $c->query('L10N'),
  80. $c->query('UserManager'),
  81. $c->query('UserSession'),
  82. $c->query('UserFolder'),
  83. $c->query('Logger')
  84. );
  85. });
  86. /**
  87. * Core class wrappers
  88. */
  89. $container->registerService('IsEncryptionEnabled', function(SimpleContainer $c) {
  90. return $c->query('ServerContainer')->getEncryptionManager()->isEnabled();
  91. });
  92. $container->registerService('URLGenerator', function(SimpleContainer $c) {
  93. return $c->query('ServerContainer')->getURLGenerator();
  94. });
  95. $container->registerService('UserManager', function(SimpleContainer $c) {
  96. return $c->query('ServerContainer')->getUserManager();
  97. });
  98. $container->registerService('Config', function(SimpleContainer $c) {
  99. return $c->query('ServerContainer')->getConfig();
  100. });
  101. $container->registerService('L10N', function(SimpleContainer $c) {
  102. return $c->query('ServerContainer')->getL10N('core');
  103. });
  104. $container->registerService('SecureRandom', function(SimpleContainer $c) {
  105. return $c->query('ServerContainer')->getSecureRandom();
  106. });
  107. $container->registerService('AvatarManager', function(SimpleContainer $c) {
  108. return $c->query('ServerContainer')->getAvatarManager();
  109. });
  110. $container->registerService('UserSession', function(SimpleContainer $c) {
  111. return $c->query('ServerContainer')->getUserSession();
  112. });
  113. $container->registerService('Cache', function(SimpleContainer $c) {
  114. return $c->query('ServerContainer')->getCache();
  115. });
  116. $container->registerService('UserFolder', function(SimpleContainer $c) {
  117. return $c->query('ServerContainer')->getUserFolder();
  118. });
  119. $container->registerService('Defaults', function() {
  120. return new \OC_Defaults;
  121. });
  122. $container->registerService('Mailer', function(SimpleContainer $c) {
  123. return $c->query('ServerContainer')->getMailer();
  124. });
  125. $container->registerService('Logger', function(SimpleContainer $c) {
  126. return $c->query('ServerContainer')->getLogger();
  127. });
  128. $container->registerService('TimeFactory', function(SimpleContainer $c) {
  129. return new TimeFactory();
  130. });
  131. $container->registerService('DefaultEmailAddress', function() {
  132. return Util::getDefaultEmailAddress('lostpassword-noreply');
  133. });
  134. }
  135. }