application.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * @author Lukas Reschke
  4. * @copyright 2014 Lukas Reschke lukas@owncloud.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 OCA\Files_Sharing;
  11. use OC\AppFramework\Utility\SimpleContainer;
  12. use OCA\Files_Sharing\Controllers\ShareController;
  13. use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
  14. use \OCP\AppFramework\App;
  15. /**
  16. * @package OCA\Files_Sharing
  17. */
  18. class Application extends App {
  19. /**
  20. * @param array $urlParams
  21. */
  22. public function __construct(array $urlParams=array()){
  23. parent::__construct('files_sharing', $urlParams);
  24. $container = $this->getContainer();
  25. /**
  26. * Controllers
  27. */
  28. $container->registerService('ShareController', function(SimpleContainer $c) {
  29. return new ShareController(
  30. $c->query('AppName'),
  31. $c->query('Request'),
  32. $c->query('UserSession'),
  33. $c->query('ServerContainer')->getAppConfig(),
  34. $c->query('ServerContainer')->getConfig(),
  35. $c->query('URLGenerator'),
  36. $c->query('ServerContainer')->getUserManager(),
  37. $c->query('ServerContainer')->getLogger()
  38. );
  39. });
  40. /**
  41. * Core class wrappers
  42. */
  43. $container->registerService('UserSession', function(SimpleContainer $c) {
  44. return $c->query('ServerContainer')->getUserSession();
  45. });
  46. $container->registerService('URLGenerator', function(SimpleContainer $c) {
  47. return $c->query('ServerContainer')->getUrlGenerator();
  48. });
  49. /**
  50. * Middleware
  51. */
  52. $container->registerService('SharingCheckMiddleware', function(SimpleContainer $c){
  53. return new SharingCheckMiddleware(
  54. $c->query('AppName'),
  55. $c->query('ServerContainer')->getAppConfig(),
  56. $c->getCoreApi()
  57. );
  58. });
  59. // Execute middlewares
  60. $container->registerMiddleware('SharingCheckMiddleware');
  61. }
  62. }