application.php 4.0 KB

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