application.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. /**
  3. * @author Victor Dubiniuk
  4. * @copyright 2014 Victor Dubiniuk victor.dubiniuk@gmail.com
  5. *
  6. * This file is licensed under the Affero General Public License version 3 or
  7. * later.
  8. * See the COPYING-README file.
  9. */
  10. namespace OC\Core;
  11. use OC\AppFramework\Utility\SimpleContainer;
  12. use \OCP\AppFramework\App;
  13. use OC\Core\LostPassword\Controller\LostController;
  14. use OC\Core\User\UserController;
  15. use \OCP\Util;
  16. /**
  17. * Class Application
  18. *
  19. * @package OC\Core
  20. */
  21. class Application extends App {
  22. /**
  23. * @param array $urlParams
  24. */
  25. public function __construct(array $urlParams=array()){
  26. parent::__construct('core', $urlParams);
  27. $container = $this->getContainer();
  28. /**
  29. * Controllers
  30. */
  31. $container->registerService('LostController', function(SimpleContainer $c) {
  32. return new LostController(
  33. $c->query('AppName'),
  34. $c->query('Request'),
  35. $c->query('URLGenerator'),
  36. $c->query('UserManager'),
  37. $c->query('Defaults'),
  38. $c->query('L10N'),
  39. $c->query('Config'),
  40. $c->query('SecureRandom'),
  41. $c->query('DefaultEmailAddress'),
  42. $c->query('IsEncryptionEnabled')
  43. );
  44. });
  45. $container->registerService('UserController', function(SimpleContainer $c) {
  46. return new UserController(
  47. $c->query('AppName'),
  48. $c->query('Request'),
  49. $c->query('UserManager'),
  50. $c->query('Defaults')
  51. );
  52. });
  53. /**
  54. * Core class wrappers
  55. */
  56. $container->registerService('IsEncryptionEnabled', function() {
  57. return \OC_App::isEnabled('files_encryption');
  58. });
  59. $container->registerService('URLGenerator', function(SimpleContainer $c) {
  60. return $c->query('ServerContainer')->getURLGenerator();
  61. });
  62. $container->registerService('UserManager', function(SimpleContainer $c) {
  63. return $c->query('ServerContainer')->getUserManager();
  64. });
  65. $container->registerService('Config', function(SimpleContainer $c) {
  66. return $c->query('ServerContainer')->getConfig();
  67. });
  68. $container->registerService('L10N', function(SimpleContainer $c) {
  69. return $c->query('ServerContainer')->getL10N('core');
  70. });
  71. $container->registerService('SecureRandom', function(SimpleContainer $c) {
  72. return $c->query('ServerContainer')->getSecureRandom();
  73. });
  74. $container->registerService('Defaults', function() {
  75. return new \OC_Defaults;
  76. });
  77. $container->registerService('DefaultEmailAddress', function() {
  78. return Util::getDefaultEmailAddress('lostpassword-noreply');
  79. });
  80. }
  81. }