Application.php 952 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace OCA\Provisioning_API\AppInfo;
  3. use OC\AppFramework\Utility\SimpleContainer;
  4. use OCA\Provisioning_API\Middleware\ProvisioningApiMiddleware;
  5. use OCP\AppFramework\App;
  6. class Application extends App {
  7. public function __construct(array $urlParams = array()) {
  8. parent::__construct('provisioning_api', $urlParams);
  9. $container = $this->getContainer();
  10. $server = $container->getServer();
  11. $container->registerService('ProvisioningApiMiddleware', function(SimpleContainer $c) use ($server) {
  12. $user = $server->getUserManager()->get($c['UserId']);
  13. $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false;
  14. $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false;
  15. return new ProvisioningApiMiddleware(
  16. $c['ControllerMethodReflector'],
  17. $isAdmin,
  18. $isSubAdmin
  19. );
  20. });
  21. $container->registerMiddleWare('ProvisioningApiMiddleware');
  22. }
  23. }