@@ -46,131 +46,131 @@ |
||
46 | 46 | use OCA\Files_Sharing\External\Manager; |
47 | 47 | |
48 | 48 | class Application extends App { |
49 | - public function __construct(array $urlParams = array()) { |
|
50 | - parent::__construct('files_sharing', $urlParams); |
|
49 | + public function __construct(array $urlParams = array()) { |
|
50 | + parent::__construct('files_sharing', $urlParams); |
|
51 | 51 | |
52 | - $container = $this->getContainer(); |
|
53 | - /** @var IServerContainer $server */ |
|
54 | - $server = $container->getServer(); |
|
52 | + $container = $this->getContainer(); |
|
53 | + /** @var IServerContainer $server */ |
|
54 | + $server = $container->getServer(); |
|
55 | 55 | |
56 | - /** |
|
57 | - * Controllers |
|
58 | - */ |
|
59 | - $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
60 | - $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
61 | - return new ShareController( |
|
62 | - $c->query('AppName'), |
|
63 | - $c->query('Request'), |
|
64 | - $server->getConfig(), |
|
65 | - $server->getURLGenerator(), |
|
66 | - $server->getUserManager(), |
|
67 | - $server->getLogger(), |
|
68 | - $server->getActivityManager(), |
|
69 | - $server->getShareManager(), |
|
70 | - $server->getSession(), |
|
71 | - $server->getPreviewManager(), |
|
72 | - $server->getRootFolder(), |
|
73 | - $federatedSharingApp->getFederatedShareProvider(), |
|
74 | - $server->getEventDispatcher(), |
|
75 | - $server->getL10N($c->query('AppName')), |
|
76 | - $server->query(Defaults::class) |
|
77 | - ); |
|
78 | - }); |
|
79 | - $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
80 | - return new ExternalSharesController( |
|
81 | - $c->query('AppName'), |
|
82 | - $c->query('Request'), |
|
83 | - $c->query('ExternalManager'), |
|
84 | - $c->query('HttpClientService') |
|
85 | - ); |
|
86 | - }); |
|
56 | + /** |
|
57 | + * Controllers |
|
58 | + */ |
|
59 | + $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
60 | + $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
|
61 | + return new ShareController( |
|
62 | + $c->query('AppName'), |
|
63 | + $c->query('Request'), |
|
64 | + $server->getConfig(), |
|
65 | + $server->getURLGenerator(), |
|
66 | + $server->getUserManager(), |
|
67 | + $server->getLogger(), |
|
68 | + $server->getActivityManager(), |
|
69 | + $server->getShareManager(), |
|
70 | + $server->getSession(), |
|
71 | + $server->getPreviewManager(), |
|
72 | + $server->getRootFolder(), |
|
73 | + $federatedSharingApp->getFederatedShareProvider(), |
|
74 | + $server->getEventDispatcher(), |
|
75 | + $server->getL10N($c->query('AppName')), |
|
76 | + $server->query(Defaults::class) |
|
77 | + ); |
|
78 | + }); |
|
79 | + $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
80 | + return new ExternalSharesController( |
|
81 | + $c->query('AppName'), |
|
82 | + $c->query('Request'), |
|
83 | + $c->query('ExternalManager'), |
|
84 | + $c->query('HttpClientService') |
|
85 | + ); |
|
86 | + }); |
|
87 | 87 | |
88 | - /** |
|
89 | - * Core class wrappers |
|
90 | - */ |
|
91 | - $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
92 | - return $server->getHTTPClientService(); |
|
93 | - }); |
|
94 | - $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
95 | - return $server->getCloudIdManager(); |
|
96 | - }); |
|
97 | - $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
98 | - $user = $server->getUserSession()->getUser(); |
|
99 | - $uid = $user ? $user->getUID() : null; |
|
100 | - return new \OCA\Files_Sharing\External\Manager( |
|
101 | - $server->getDatabaseConnection(), |
|
102 | - \OC\Files\Filesystem::getMountManager(), |
|
103 | - \OC\Files\Filesystem::getLoader(), |
|
104 | - $server->getHTTPClientService(), |
|
105 | - $server->getNotificationManager(), |
|
106 | - $server->query(\OCP\OCS\IDiscoveryService::class), |
|
107 | - $server->getCloudFederationProviderManager(), |
|
108 | - $server->getCloudFederationFactory(), |
|
109 | - $server->getGroupManager(), |
|
110 | - $server->getUserManager(), |
|
111 | - $uid |
|
112 | - ); |
|
113 | - }); |
|
114 | - $container->registerAlias(Manager::class, 'ExternalManager'); |
|
88 | + /** |
|
89 | + * Core class wrappers |
|
90 | + */ |
|
91 | + $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
92 | + return $server->getHTTPClientService(); |
|
93 | + }); |
|
94 | + $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
95 | + return $server->getCloudIdManager(); |
|
96 | + }); |
|
97 | + $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
98 | + $user = $server->getUserSession()->getUser(); |
|
99 | + $uid = $user ? $user->getUID() : null; |
|
100 | + return new \OCA\Files_Sharing\External\Manager( |
|
101 | + $server->getDatabaseConnection(), |
|
102 | + \OC\Files\Filesystem::getMountManager(), |
|
103 | + \OC\Files\Filesystem::getLoader(), |
|
104 | + $server->getHTTPClientService(), |
|
105 | + $server->getNotificationManager(), |
|
106 | + $server->query(\OCP\OCS\IDiscoveryService::class), |
|
107 | + $server->getCloudFederationProviderManager(), |
|
108 | + $server->getCloudFederationFactory(), |
|
109 | + $server->getGroupManager(), |
|
110 | + $server->getUserManager(), |
|
111 | + $uid |
|
112 | + ); |
|
113 | + }); |
|
114 | + $container->registerAlias(Manager::class, 'ExternalManager'); |
|
115 | 115 | |
116 | - /** |
|
117 | - * Middleware |
|
118 | - */ |
|
119 | - $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
120 | - return new SharingCheckMiddleware( |
|
121 | - $c->query('AppName'), |
|
122 | - $server->getConfig(), |
|
123 | - $server->getAppManager(), |
|
124 | - $server->query(IControllerMethodReflector::class), |
|
125 | - $server->getShareManager(), |
|
126 | - $server->getRequest() |
|
127 | - ); |
|
128 | - }); |
|
116 | + /** |
|
117 | + * Middleware |
|
118 | + */ |
|
119 | + $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
120 | + return new SharingCheckMiddleware( |
|
121 | + $c->query('AppName'), |
|
122 | + $server->getConfig(), |
|
123 | + $server->getAppManager(), |
|
124 | + $server->query(IControllerMethodReflector::class), |
|
125 | + $server->getShareManager(), |
|
126 | + $server->getRequest() |
|
127 | + ); |
|
128 | + }); |
|
129 | 129 | |
130 | - $container->registerService(ShareInfoMiddleware::class, function () use ($server) { |
|
131 | - return new ShareInfoMiddleware( |
|
132 | - $server->getShareManager() |
|
133 | - ); |
|
134 | - }); |
|
130 | + $container->registerService(ShareInfoMiddleware::class, function () use ($server) { |
|
131 | + return new ShareInfoMiddleware( |
|
132 | + $server->getShareManager() |
|
133 | + ); |
|
134 | + }); |
|
135 | 135 | |
136 | - // Execute middlewares |
|
137 | - $container->registerMiddleWare('SharingCheckMiddleware'); |
|
138 | - $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
139 | - $container->registerMiddleWare(ShareInfoMiddleware::class); |
|
136 | + // Execute middlewares |
|
137 | + $container->registerMiddleWare('SharingCheckMiddleware'); |
|
138 | + $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
|
139 | + $container->registerMiddleWare(ShareInfoMiddleware::class); |
|
140 | 140 | |
141 | - $container->registerService('MountProvider', function (IContainer $c) { |
|
142 | - /** @var \OCP\IServerContainer $server */ |
|
143 | - $server = $c->query('ServerContainer'); |
|
144 | - return new MountProvider( |
|
145 | - $server->getConfig(), |
|
146 | - $server->getShareManager(), |
|
147 | - $server->getLogger() |
|
148 | - ); |
|
149 | - }); |
|
141 | + $container->registerService('MountProvider', function (IContainer $c) { |
|
142 | + /** @var \OCP\IServerContainer $server */ |
|
143 | + $server = $c->query('ServerContainer'); |
|
144 | + return new MountProvider( |
|
145 | + $server->getConfig(), |
|
146 | + $server->getShareManager(), |
|
147 | + $server->getLogger() |
|
148 | + ); |
|
149 | + }); |
|
150 | 150 | |
151 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
152 | - /** @var \OCP\IServerContainer $server */ |
|
153 | - $server = $c->query('ServerContainer'); |
|
154 | - return new \OCA\Files_Sharing\External\MountProvider( |
|
155 | - $server->getDatabaseConnection(), |
|
156 | - function() use ($c) { |
|
157 | - return $c->query('ExternalManager'); |
|
158 | - }, |
|
159 | - $server->getCloudIdManager() |
|
160 | - ); |
|
161 | - }); |
|
151 | + $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
152 | + /** @var \OCP\IServerContainer $server */ |
|
153 | + $server = $c->query('ServerContainer'); |
|
154 | + return new \OCA\Files_Sharing\External\MountProvider( |
|
155 | + $server->getDatabaseConnection(), |
|
156 | + function() use ($c) { |
|
157 | + return $c->query('ExternalManager'); |
|
158 | + }, |
|
159 | + $server->getCloudIdManager() |
|
160 | + ); |
|
161 | + }); |
|
162 | 162 | |
163 | - /* |
|
163 | + /* |
|
164 | 164 | * Register capabilities |
165 | 165 | */ |
166 | - $container->registerCapability(Capabilities::class); |
|
167 | - } |
|
166 | + $container->registerCapability(Capabilities::class); |
|
167 | + } |
|
168 | 168 | |
169 | - public function registerMountProviders() { |
|
170 | - /** @var \OCP\IServerContainer $server */ |
|
171 | - $server = $this->getContainer()->query('ServerContainer'); |
|
172 | - $mountProviderCollection = $server->getMountProviderCollection(); |
|
173 | - $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); |
|
174 | - $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
175 | - } |
|
169 | + public function registerMountProviders() { |
|
170 | + /** @var \OCP\IServerContainer $server */ |
|
171 | + $server = $this->getContainer()->query('ServerContainer'); |
|
172 | + $mountProviderCollection = $server->getMountProviderCollection(); |
|
173 | + $mountProviderCollection->registerProvider($this->getContainer()->query('MountProvider')); |
|
174 | + $mountProviderCollection->registerProvider($this->getContainer()->query('ExternalMountProvider')); |
|
175 | + } |
|
176 | 176 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | /** |
57 | 57 | * Controllers |
58 | 58 | */ |
59 | - $container->registerService('ShareController', function (SimpleContainer $c) use ($server) { |
|
59 | + $container->registerService('ShareController', function(SimpleContainer $c) use ($server) { |
|
60 | 60 | $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application(); |
61 | 61 | return new ShareController( |
62 | 62 | $c->query('AppName'), |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $server->query(Defaults::class) |
77 | 77 | ); |
78 | 78 | }); |
79 | - $container->registerService('ExternalSharesController', function (SimpleContainer $c) { |
|
79 | + $container->registerService('ExternalSharesController', function(SimpleContainer $c) { |
|
80 | 80 | return new ExternalSharesController( |
81 | 81 | $c->query('AppName'), |
82 | 82 | $c->query('Request'), |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | /** |
89 | 89 | * Core class wrappers |
90 | 90 | */ |
91 | - $container->registerService('HttpClientService', function (SimpleContainer $c) use ($server) { |
|
91 | + $container->registerService('HttpClientService', function(SimpleContainer $c) use ($server) { |
|
92 | 92 | return $server->getHTTPClientService(); |
93 | 93 | }); |
94 | - $container->registerService(ICloudIdManager::class, function (SimpleContainer $c) use ($server) { |
|
94 | + $container->registerService(ICloudIdManager::class, function(SimpleContainer $c) use ($server) { |
|
95 | 95 | return $server->getCloudIdManager(); |
96 | 96 | }); |
97 | - $container->registerService('ExternalManager', function (SimpleContainer $c) use ($server) { |
|
97 | + $container->registerService('ExternalManager', function(SimpleContainer $c) use ($server) { |
|
98 | 98 | $user = $server->getUserSession()->getUser(); |
99 | 99 | $uid = $user ? $user->getUID() : null; |
100 | 100 | return new \OCA\Files_Sharing\External\Manager( |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Middleware |
118 | 118 | */ |
119 | - $container->registerService('SharingCheckMiddleware', function (SimpleContainer $c) use ($server) { |
|
119 | + $container->registerService('SharingCheckMiddleware', function(SimpleContainer $c) use ($server) { |
|
120 | 120 | return new SharingCheckMiddleware( |
121 | 121 | $c->query('AppName'), |
122 | 122 | $server->getConfig(), |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | ); |
128 | 128 | }); |
129 | 129 | |
130 | - $container->registerService(ShareInfoMiddleware::class, function () use ($server) { |
|
130 | + $container->registerService(ShareInfoMiddleware::class, function() use ($server) { |
|
131 | 131 | return new ShareInfoMiddleware( |
132 | 132 | $server->getShareManager() |
133 | 133 | ); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $container->registerMiddleWare(OCSShareAPIMiddleware::class); |
139 | 139 | $container->registerMiddleWare(ShareInfoMiddleware::class); |
140 | 140 | |
141 | - $container->registerService('MountProvider', function (IContainer $c) { |
|
141 | + $container->registerService('MountProvider', function(IContainer $c) { |
|
142 | 142 | /** @var \OCP\IServerContainer $server */ |
143 | 143 | $server = $c->query('ServerContainer'); |
144 | 144 | return new MountProvider( |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | ); |
149 | 149 | }); |
150 | 150 | |
151 | - $container->registerService('ExternalMountProvider', function (IContainer $c) { |
|
151 | + $container->registerService('ExternalMountProvider', function(IContainer $c) { |
|
152 | 152 | /** @var \OCP\IServerContainer $server */ |
153 | 153 | $server = $c->query('ServerContainer'); |
154 | 154 | return new \OCA\Files_Sharing\External\MountProvider( |
@@ -69,353 +69,353 @@ |
||
69 | 69 | |
70 | 70 | class DIContainer extends SimpleContainer implements IAppContainer { |
71 | 71 | |
72 | - /** |
|
73 | - * @var array |
|
74 | - */ |
|
75 | - private $middleWares = []; |
|
76 | - |
|
77 | - /** @var ServerContainer */ |
|
78 | - private $server; |
|
79 | - |
|
80 | - /** |
|
81 | - * Put your class dependencies in here |
|
82 | - * @param string $appName the name of the app |
|
83 | - * @param array $urlParams |
|
84 | - * @param ServerContainer|null $server |
|
85 | - */ |
|
86 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
87 | - parent::__construct(); |
|
88 | - $this['AppName'] = $appName; |
|
89 | - $this['urlParams'] = $urlParams; |
|
90 | - |
|
91 | - $this->registerAlias('Request', IRequest::class); |
|
92 | - |
|
93 | - /** @var \OC\ServerContainer $server */ |
|
94 | - if ($server === null) { |
|
95 | - $server = \OC::$server; |
|
96 | - } |
|
97 | - $this->server = $server; |
|
98 | - $this->server->registerAppContainer($appName, $this); |
|
99 | - |
|
100 | - // aliases |
|
101 | - $this->registerAlias('appName', 'AppName'); |
|
102 | - $this->registerAlias('webRoot', 'WebRoot'); |
|
103 | - $this->registerAlias('userId', 'UserId'); |
|
104 | - |
|
105 | - /** |
|
106 | - * Core services |
|
107 | - */ |
|
108 | - $this->registerService(IOutput::class, function(){ |
|
109 | - return new Output($this->getServer()->getWebRoot()); |
|
110 | - }); |
|
111 | - |
|
112 | - $this->registerService(Folder::class, function() { |
|
113 | - return $this->getServer()->getUserFolder(); |
|
114 | - }); |
|
115 | - |
|
116 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
117 | - return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
118 | - }); |
|
119 | - |
|
120 | - $this->registerService(IL10N::class, function($c) { |
|
121 | - return $this->getServer()->getL10N($c->query('AppName')); |
|
122 | - }); |
|
123 | - |
|
124 | - // Log wrapper |
|
125 | - $this->registerService(ILogger::class, function ($c) { |
|
126 | - return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->query('AppName')); |
|
127 | - }); |
|
128 | - |
|
129 | - $this->registerService(IServerContainer::class, function () { |
|
130 | - return $this->getServer(); |
|
131 | - }); |
|
132 | - $this->registerAlias('ServerContainer', IServerContainer::class); |
|
133 | - |
|
134 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
135 | - return $c->query(Manager::class); |
|
136 | - }); |
|
137 | - |
|
138 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
139 | - return $c; |
|
140 | - }); |
|
141 | - |
|
142 | - // commonly used attributes |
|
143 | - $this->registerService('UserId', function ($c) { |
|
144 | - return $c->query(IUserSession::class)->getSession()->get('user_id'); |
|
145 | - }); |
|
146 | - |
|
147 | - $this->registerService('WebRoot', function ($c) { |
|
148 | - return $c->query('ServerContainer')->getWebRoot(); |
|
149 | - }); |
|
150 | - |
|
151 | - $this->registerService('OC_Defaults', function ($c) { |
|
152 | - return $c->getServer()->getThemingDefaults(); |
|
153 | - }); |
|
154 | - |
|
155 | - $this->registerService(IConfig::class, function ($c) { |
|
156 | - return $c->query(OC\GlobalScale\Config::class); |
|
157 | - }); |
|
158 | - |
|
159 | - $this->registerService('Protocol', function($c){ |
|
160 | - /** @var \OC\Server $server */ |
|
161 | - $server = $c->query('ServerContainer'); |
|
162 | - $protocol = $server->getRequest()->getHttpProtocol(); |
|
163 | - return new Http($_SERVER, $protocol); |
|
164 | - }); |
|
165 | - |
|
166 | - $this->registerService('Dispatcher', function($c) { |
|
167 | - return new Dispatcher( |
|
168 | - $c['Protocol'], |
|
169 | - $c['MiddlewareDispatcher'], |
|
170 | - $c->query(IControllerMethodReflector::class), |
|
171 | - $c['Request'] |
|
172 | - ); |
|
173 | - }); |
|
174 | - |
|
175 | - /** |
|
176 | - * App Framework default arguments |
|
177 | - */ |
|
178 | - $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
179 | - $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
180 | - $this->registerParameter('corsMaxAge', 1728000); |
|
181 | - |
|
182 | - /** |
|
183 | - * Middleware |
|
184 | - */ |
|
185 | - $this->registerService('MiddlewareDispatcher', function(SimpleContainer $c) { |
|
186 | - $server = $this->getServer(); |
|
187 | - |
|
188 | - $dispatcher = new MiddlewareDispatcher(); |
|
189 | - $dispatcher->registerMiddleware( |
|
190 | - $c->query(OC\AppFramework\Middleware\Security\ReloadExecutionMiddleware::class) |
|
191 | - ); |
|
192 | - |
|
193 | - $dispatcher->registerMiddleware( |
|
194 | - new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware( |
|
195 | - $c->query(IRequest::class), |
|
196 | - $c->query(IControllerMethodReflector::class) |
|
197 | - ) |
|
198 | - ); |
|
199 | - $dispatcher->registerMiddleware( |
|
200 | - new CORSMiddleware( |
|
201 | - $c->query(IRequest::class), |
|
202 | - $c->query(IControllerMethodReflector::class), |
|
203 | - $c->query(IUserSession::class), |
|
204 | - $c->query(OC\Security\Bruteforce\Throttler::class) |
|
205 | - ) |
|
206 | - ); |
|
207 | - $dispatcher->registerMiddleware( |
|
208 | - new OCSMiddleware( |
|
209 | - $c->query(IRequest::class) |
|
210 | - ) |
|
211 | - ); |
|
212 | - |
|
213 | - $securityMiddleware = new SecurityMiddleware( |
|
214 | - $c->query(IRequest::class), |
|
215 | - $c->query(IControllerMethodReflector::class), |
|
216 | - $c->query(INavigationManager::class), |
|
217 | - $c->query(IURLGenerator::class), |
|
218 | - $server->getLogger(), |
|
219 | - $c['AppName'], |
|
220 | - $server->getUserSession()->isLoggedIn(), |
|
221 | - $server->getGroupManager()->isAdmin($this->getUserId()), |
|
222 | - $server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()), |
|
223 | - $server->getAppManager(), |
|
224 | - $server->getL10N('lib') |
|
225 | - ); |
|
226 | - $dispatcher->registerMiddleware($securityMiddleware); |
|
227 | - $dispatcher->registerMiddleware( |
|
228 | - new OC\AppFramework\Middleware\Security\CSPMiddleware( |
|
229 | - $server->query(OC\Security\CSP\ContentSecurityPolicyManager::class), |
|
230 | - $server->query(OC\Security\CSP\ContentSecurityPolicyNonceManager::class), |
|
231 | - $server->query(OC\Security\CSRF\CsrfTokenManager::class) |
|
232 | - ) |
|
233 | - ); |
|
234 | - $dispatcher->registerMiddleware( |
|
235 | - $server->query(OC\AppFramework\Middleware\Security\FeaturePolicyMiddleware::class) |
|
236 | - ); |
|
237 | - $dispatcher->registerMiddleware( |
|
238 | - new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware( |
|
239 | - $c->query(IControllerMethodReflector::class), |
|
240 | - $c->query(ISession::class), |
|
241 | - $c->query(IUserSession::class), |
|
242 | - $c->query(ITimeFactory::class) |
|
243 | - ) |
|
244 | - ); |
|
245 | - $dispatcher->registerMiddleware( |
|
246 | - new TwoFactorMiddleware( |
|
247 | - $c->query(OC\Authentication\TwoFactorAuth\Manager::class), |
|
248 | - $c->query(IUserSession::class), |
|
249 | - $c->query(ISession::class), |
|
250 | - $c->query(IURLGenerator::class), |
|
251 | - $c->query(IControllerMethodReflector::class), |
|
252 | - $c->query(IRequest::class) |
|
253 | - ) |
|
254 | - ); |
|
255 | - $dispatcher->registerMiddleware( |
|
256 | - new OC\AppFramework\Middleware\Security\BruteForceMiddleware( |
|
257 | - $c->query(IControllerMethodReflector::class), |
|
258 | - $c->query(OC\Security\Bruteforce\Throttler::class), |
|
259 | - $c->query(IRequest::class) |
|
260 | - ) |
|
261 | - ); |
|
262 | - $dispatcher->registerMiddleware( |
|
263 | - new RateLimitingMiddleware( |
|
264 | - $c->query(IRequest::class), |
|
265 | - $c->query(IUserSession::class), |
|
266 | - $c->query(IControllerMethodReflector::class), |
|
267 | - $c->query(OC\Security\RateLimiting\Limiter::class) |
|
268 | - ) |
|
269 | - ); |
|
270 | - $dispatcher->registerMiddleware( |
|
271 | - new OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware( |
|
272 | - $c->query(IRequest::class), |
|
273 | - $c->query(ISession::class), |
|
274 | - $c->query(\OCP\IConfig::class) |
|
275 | - ) |
|
276 | - ); |
|
277 | - $dispatcher->registerMiddleware( |
|
278 | - $c->query(\OC\AppFramework\Middleware\AdditionalScriptsMiddleware::class) |
|
279 | - ); |
|
280 | - |
|
281 | - foreach($this->middleWares as $middleWare) { |
|
282 | - $dispatcher->registerMiddleware($c->query($middleWare)); |
|
283 | - } |
|
284 | - |
|
285 | - $dispatcher->registerMiddleware( |
|
286 | - new SessionMiddleware( |
|
287 | - $c->query(IControllerMethodReflector::class), |
|
288 | - $c->query(ISession::class) |
|
289 | - ) |
|
290 | - ); |
|
291 | - return $dispatcher; |
|
292 | - }); |
|
293 | - |
|
294 | - $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, OC\Collaboration\Resources\Manager::class); |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * @return \OCP\IServerContainer |
|
299 | - */ |
|
300 | - public function getServer() |
|
301 | - { |
|
302 | - return $this->server; |
|
303 | - } |
|
304 | - |
|
305 | - /** |
|
306 | - * @param string $middleWare |
|
307 | - * @return boolean|null |
|
308 | - */ |
|
309 | - public function registerMiddleWare($middleWare) { |
|
310 | - if (in_array($middleWare, $this->middleWares, true) !== false) { |
|
311 | - return false; |
|
312 | - } |
|
313 | - $this->middleWares[] = $middleWare; |
|
314 | - } |
|
315 | - |
|
316 | - /** |
|
317 | - * used to return the appname of the set application |
|
318 | - * @return string the name of your application |
|
319 | - */ |
|
320 | - public function getAppName() { |
|
321 | - return $this->query('AppName'); |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * @deprecated use IUserSession->isLoggedIn() |
|
326 | - * @return boolean |
|
327 | - */ |
|
328 | - public function isLoggedIn() { |
|
329 | - return \OC::$server->getUserSession()->isLoggedIn(); |
|
330 | - } |
|
331 | - |
|
332 | - /** |
|
333 | - * @deprecated use IGroupManager->isAdmin($userId) |
|
334 | - * @return boolean |
|
335 | - */ |
|
336 | - public function isAdminUser() { |
|
337 | - $uid = $this->getUserId(); |
|
338 | - return \OC_User::isAdminUser($uid); |
|
339 | - } |
|
340 | - |
|
341 | - private function getUserId() { |
|
342 | - return $this->getServer()->getSession()->get('user_id'); |
|
343 | - } |
|
344 | - |
|
345 | - /** |
|
346 | - * @deprecated use the ILogger instead |
|
347 | - * @param string $message |
|
348 | - * @param string $level |
|
349 | - * @return mixed |
|
350 | - */ |
|
351 | - public function log($message, $level) { |
|
352 | - switch($level){ |
|
353 | - case 'debug': |
|
354 | - $level = ILogger::DEBUG; |
|
355 | - break; |
|
356 | - case 'info': |
|
357 | - $level = ILogger::INFO; |
|
358 | - break; |
|
359 | - case 'warn': |
|
360 | - $level = ILogger::WARN; |
|
361 | - break; |
|
362 | - case 'fatal': |
|
363 | - $level = ILogger::FATAL; |
|
364 | - break; |
|
365 | - default: |
|
366 | - $level = ILogger::ERROR; |
|
367 | - break; |
|
368 | - } |
|
369 | - \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
370 | - } |
|
371 | - |
|
372 | - /** |
|
373 | - * Register a capability |
|
374 | - * |
|
375 | - * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
376 | - */ |
|
377 | - public function registerCapability($serviceName) { |
|
378 | - $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
379 | - return $this->query($serviceName); |
|
380 | - }); |
|
381 | - } |
|
382 | - |
|
383 | - public function query(string $name, bool $autoload = true) { |
|
384 | - try { |
|
385 | - return $this->queryNoFallback($name); |
|
386 | - } catch (QueryException $firstException) { |
|
387 | - try { |
|
388 | - return $this->getServer()->query($name, $autoload); |
|
389 | - } catch (QueryException $secondException) { |
|
390 | - if ($firstException->getCode() === 1) { |
|
391 | - throw $secondException; |
|
392 | - } |
|
393 | - throw $firstException; |
|
394 | - } |
|
395 | - } |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * @param string $name |
|
400 | - * @return mixed |
|
401 | - * @throws QueryException if the query could not be resolved |
|
402 | - */ |
|
403 | - public function queryNoFallback($name) { |
|
404 | - $name = $this->sanitizeName($name); |
|
405 | - |
|
406 | - if ($this->offsetExists($name)) { |
|
407 | - return parent::query($name); |
|
408 | - } else { |
|
409 | - if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
410 | - return parent::query($name); |
|
411 | - } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
412 | - return parent::query($name); |
|
413 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
414 | - return parent::query($name); |
|
415 | - } |
|
416 | - } |
|
417 | - |
|
418 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
419 | - ' Class can not be instantiated', 1); |
|
420 | - } |
|
72 | + /** |
|
73 | + * @var array |
|
74 | + */ |
|
75 | + private $middleWares = []; |
|
76 | + |
|
77 | + /** @var ServerContainer */ |
|
78 | + private $server; |
|
79 | + |
|
80 | + /** |
|
81 | + * Put your class dependencies in here |
|
82 | + * @param string $appName the name of the app |
|
83 | + * @param array $urlParams |
|
84 | + * @param ServerContainer|null $server |
|
85 | + */ |
|
86 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
87 | + parent::__construct(); |
|
88 | + $this['AppName'] = $appName; |
|
89 | + $this['urlParams'] = $urlParams; |
|
90 | + |
|
91 | + $this->registerAlias('Request', IRequest::class); |
|
92 | + |
|
93 | + /** @var \OC\ServerContainer $server */ |
|
94 | + if ($server === null) { |
|
95 | + $server = \OC::$server; |
|
96 | + } |
|
97 | + $this->server = $server; |
|
98 | + $this->server->registerAppContainer($appName, $this); |
|
99 | + |
|
100 | + // aliases |
|
101 | + $this->registerAlias('appName', 'AppName'); |
|
102 | + $this->registerAlias('webRoot', 'WebRoot'); |
|
103 | + $this->registerAlias('userId', 'UserId'); |
|
104 | + |
|
105 | + /** |
|
106 | + * Core services |
|
107 | + */ |
|
108 | + $this->registerService(IOutput::class, function(){ |
|
109 | + return new Output($this->getServer()->getWebRoot()); |
|
110 | + }); |
|
111 | + |
|
112 | + $this->registerService(Folder::class, function() { |
|
113 | + return $this->getServer()->getUserFolder(); |
|
114 | + }); |
|
115 | + |
|
116 | + $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
117 | + return $this->getServer()->getAppDataDir($c->query('AppName')); |
|
118 | + }); |
|
119 | + |
|
120 | + $this->registerService(IL10N::class, function($c) { |
|
121 | + return $this->getServer()->getL10N($c->query('AppName')); |
|
122 | + }); |
|
123 | + |
|
124 | + // Log wrapper |
|
125 | + $this->registerService(ILogger::class, function ($c) { |
|
126 | + return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->query('AppName')); |
|
127 | + }); |
|
128 | + |
|
129 | + $this->registerService(IServerContainer::class, function () { |
|
130 | + return $this->getServer(); |
|
131 | + }); |
|
132 | + $this->registerAlias('ServerContainer', IServerContainer::class); |
|
133 | + |
|
134 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
135 | + return $c->query(Manager::class); |
|
136 | + }); |
|
137 | + |
|
138 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
139 | + return $c; |
|
140 | + }); |
|
141 | + |
|
142 | + // commonly used attributes |
|
143 | + $this->registerService('UserId', function ($c) { |
|
144 | + return $c->query(IUserSession::class)->getSession()->get('user_id'); |
|
145 | + }); |
|
146 | + |
|
147 | + $this->registerService('WebRoot', function ($c) { |
|
148 | + return $c->query('ServerContainer')->getWebRoot(); |
|
149 | + }); |
|
150 | + |
|
151 | + $this->registerService('OC_Defaults', function ($c) { |
|
152 | + return $c->getServer()->getThemingDefaults(); |
|
153 | + }); |
|
154 | + |
|
155 | + $this->registerService(IConfig::class, function ($c) { |
|
156 | + return $c->query(OC\GlobalScale\Config::class); |
|
157 | + }); |
|
158 | + |
|
159 | + $this->registerService('Protocol', function($c){ |
|
160 | + /** @var \OC\Server $server */ |
|
161 | + $server = $c->query('ServerContainer'); |
|
162 | + $protocol = $server->getRequest()->getHttpProtocol(); |
|
163 | + return new Http($_SERVER, $protocol); |
|
164 | + }); |
|
165 | + |
|
166 | + $this->registerService('Dispatcher', function($c) { |
|
167 | + return new Dispatcher( |
|
168 | + $c['Protocol'], |
|
169 | + $c['MiddlewareDispatcher'], |
|
170 | + $c->query(IControllerMethodReflector::class), |
|
171 | + $c['Request'] |
|
172 | + ); |
|
173 | + }); |
|
174 | + |
|
175 | + /** |
|
176 | + * App Framework default arguments |
|
177 | + */ |
|
178 | + $this->registerParameter('corsMethods', 'PUT, POST, GET, DELETE, PATCH'); |
|
179 | + $this->registerParameter('corsAllowedHeaders', 'Authorization, Content-Type, Accept'); |
|
180 | + $this->registerParameter('corsMaxAge', 1728000); |
|
181 | + |
|
182 | + /** |
|
183 | + * Middleware |
|
184 | + */ |
|
185 | + $this->registerService('MiddlewareDispatcher', function(SimpleContainer $c) { |
|
186 | + $server = $this->getServer(); |
|
187 | + |
|
188 | + $dispatcher = new MiddlewareDispatcher(); |
|
189 | + $dispatcher->registerMiddleware( |
|
190 | + $c->query(OC\AppFramework\Middleware\Security\ReloadExecutionMiddleware::class) |
|
191 | + ); |
|
192 | + |
|
193 | + $dispatcher->registerMiddleware( |
|
194 | + new OC\AppFramework\Middleware\Security\SameSiteCookieMiddleware( |
|
195 | + $c->query(IRequest::class), |
|
196 | + $c->query(IControllerMethodReflector::class) |
|
197 | + ) |
|
198 | + ); |
|
199 | + $dispatcher->registerMiddleware( |
|
200 | + new CORSMiddleware( |
|
201 | + $c->query(IRequest::class), |
|
202 | + $c->query(IControllerMethodReflector::class), |
|
203 | + $c->query(IUserSession::class), |
|
204 | + $c->query(OC\Security\Bruteforce\Throttler::class) |
|
205 | + ) |
|
206 | + ); |
|
207 | + $dispatcher->registerMiddleware( |
|
208 | + new OCSMiddleware( |
|
209 | + $c->query(IRequest::class) |
|
210 | + ) |
|
211 | + ); |
|
212 | + |
|
213 | + $securityMiddleware = new SecurityMiddleware( |
|
214 | + $c->query(IRequest::class), |
|
215 | + $c->query(IControllerMethodReflector::class), |
|
216 | + $c->query(INavigationManager::class), |
|
217 | + $c->query(IURLGenerator::class), |
|
218 | + $server->getLogger(), |
|
219 | + $c['AppName'], |
|
220 | + $server->getUserSession()->isLoggedIn(), |
|
221 | + $server->getGroupManager()->isAdmin($this->getUserId()), |
|
222 | + $server->getUserSession()->getUser() !== null && $server->query(ISubAdmin::class)->isSubAdmin($server->getUserSession()->getUser()), |
|
223 | + $server->getAppManager(), |
|
224 | + $server->getL10N('lib') |
|
225 | + ); |
|
226 | + $dispatcher->registerMiddleware($securityMiddleware); |
|
227 | + $dispatcher->registerMiddleware( |
|
228 | + new OC\AppFramework\Middleware\Security\CSPMiddleware( |
|
229 | + $server->query(OC\Security\CSP\ContentSecurityPolicyManager::class), |
|
230 | + $server->query(OC\Security\CSP\ContentSecurityPolicyNonceManager::class), |
|
231 | + $server->query(OC\Security\CSRF\CsrfTokenManager::class) |
|
232 | + ) |
|
233 | + ); |
|
234 | + $dispatcher->registerMiddleware( |
|
235 | + $server->query(OC\AppFramework\Middleware\Security\FeaturePolicyMiddleware::class) |
|
236 | + ); |
|
237 | + $dispatcher->registerMiddleware( |
|
238 | + new OC\AppFramework\Middleware\Security\PasswordConfirmationMiddleware( |
|
239 | + $c->query(IControllerMethodReflector::class), |
|
240 | + $c->query(ISession::class), |
|
241 | + $c->query(IUserSession::class), |
|
242 | + $c->query(ITimeFactory::class) |
|
243 | + ) |
|
244 | + ); |
|
245 | + $dispatcher->registerMiddleware( |
|
246 | + new TwoFactorMiddleware( |
|
247 | + $c->query(OC\Authentication\TwoFactorAuth\Manager::class), |
|
248 | + $c->query(IUserSession::class), |
|
249 | + $c->query(ISession::class), |
|
250 | + $c->query(IURLGenerator::class), |
|
251 | + $c->query(IControllerMethodReflector::class), |
|
252 | + $c->query(IRequest::class) |
|
253 | + ) |
|
254 | + ); |
|
255 | + $dispatcher->registerMiddleware( |
|
256 | + new OC\AppFramework\Middleware\Security\BruteForceMiddleware( |
|
257 | + $c->query(IControllerMethodReflector::class), |
|
258 | + $c->query(OC\Security\Bruteforce\Throttler::class), |
|
259 | + $c->query(IRequest::class) |
|
260 | + ) |
|
261 | + ); |
|
262 | + $dispatcher->registerMiddleware( |
|
263 | + new RateLimitingMiddleware( |
|
264 | + $c->query(IRequest::class), |
|
265 | + $c->query(IUserSession::class), |
|
266 | + $c->query(IControllerMethodReflector::class), |
|
267 | + $c->query(OC\Security\RateLimiting\Limiter::class) |
|
268 | + ) |
|
269 | + ); |
|
270 | + $dispatcher->registerMiddleware( |
|
271 | + new OC\AppFramework\Middleware\PublicShare\PublicShareMiddleware( |
|
272 | + $c->query(IRequest::class), |
|
273 | + $c->query(ISession::class), |
|
274 | + $c->query(\OCP\IConfig::class) |
|
275 | + ) |
|
276 | + ); |
|
277 | + $dispatcher->registerMiddleware( |
|
278 | + $c->query(\OC\AppFramework\Middleware\AdditionalScriptsMiddleware::class) |
|
279 | + ); |
|
280 | + |
|
281 | + foreach($this->middleWares as $middleWare) { |
|
282 | + $dispatcher->registerMiddleware($c->query($middleWare)); |
|
283 | + } |
|
284 | + |
|
285 | + $dispatcher->registerMiddleware( |
|
286 | + new SessionMiddleware( |
|
287 | + $c->query(IControllerMethodReflector::class), |
|
288 | + $c->query(ISession::class) |
|
289 | + ) |
|
290 | + ); |
|
291 | + return $dispatcher; |
|
292 | + }); |
|
293 | + |
|
294 | + $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, OC\Collaboration\Resources\Manager::class); |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * @return \OCP\IServerContainer |
|
299 | + */ |
|
300 | + public function getServer() |
|
301 | + { |
|
302 | + return $this->server; |
|
303 | + } |
|
304 | + |
|
305 | + /** |
|
306 | + * @param string $middleWare |
|
307 | + * @return boolean|null |
|
308 | + */ |
|
309 | + public function registerMiddleWare($middleWare) { |
|
310 | + if (in_array($middleWare, $this->middleWares, true) !== false) { |
|
311 | + return false; |
|
312 | + } |
|
313 | + $this->middleWares[] = $middleWare; |
|
314 | + } |
|
315 | + |
|
316 | + /** |
|
317 | + * used to return the appname of the set application |
|
318 | + * @return string the name of your application |
|
319 | + */ |
|
320 | + public function getAppName() { |
|
321 | + return $this->query('AppName'); |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * @deprecated use IUserSession->isLoggedIn() |
|
326 | + * @return boolean |
|
327 | + */ |
|
328 | + public function isLoggedIn() { |
|
329 | + return \OC::$server->getUserSession()->isLoggedIn(); |
|
330 | + } |
|
331 | + |
|
332 | + /** |
|
333 | + * @deprecated use IGroupManager->isAdmin($userId) |
|
334 | + * @return boolean |
|
335 | + */ |
|
336 | + public function isAdminUser() { |
|
337 | + $uid = $this->getUserId(); |
|
338 | + return \OC_User::isAdminUser($uid); |
|
339 | + } |
|
340 | + |
|
341 | + private function getUserId() { |
|
342 | + return $this->getServer()->getSession()->get('user_id'); |
|
343 | + } |
|
344 | + |
|
345 | + /** |
|
346 | + * @deprecated use the ILogger instead |
|
347 | + * @param string $message |
|
348 | + * @param string $level |
|
349 | + * @return mixed |
|
350 | + */ |
|
351 | + public function log($message, $level) { |
|
352 | + switch($level){ |
|
353 | + case 'debug': |
|
354 | + $level = ILogger::DEBUG; |
|
355 | + break; |
|
356 | + case 'info': |
|
357 | + $level = ILogger::INFO; |
|
358 | + break; |
|
359 | + case 'warn': |
|
360 | + $level = ILogger::WARN; |
|
361 | + break; |
|
362 | + case 'fatal': |
|
363 | + $level = ILogger::FATAL; |
|
364 | + break; |
|
365 | + default: |
|
366 | + $level = ILogger::ERROR; |
|
367 | + break; |
|
368 | + } |
|
369 | + \OCP\Util::writeLog($this->getAppName(), $message, $level); |
|
370 | + } |
|
371 | + |
|
372 | + /** |
|
373 | + * Register a capability |
|
374 | + * |
|
375 | + * @param string $serviceName e.g. 'OCA\Files\Capabilities' |
|
376 | + */ |
|
377 | + public function registerCapability($serviceName) { |
|
378 | + $this->query('OC\CapabilitiesManager')->registerCapability(function() use ($serviceName) { |
|
379 | + return $this->query($serviceName); |
|
380 | + }); |
|
381 | + } |
|
382 | + |
|
383 | + public function query(string $name, bool $autoload = true) { |
|
384 | + try { |
|
385 | + return $this->queryNoFallback($name); |
|
386 | + } catch (QueryException $firstException) { |
|
387 | + try { |
|
388 | + return $this->getServer()->query($name, $autoload); |
|
389 | + } catch (QueryException $secondException) { |
|
390 | + if ($firstException->getCode() === 1) { |
|
391 | + throw $secondException; |
|
392 | + } |
|
393 | + throw $firstException; |
|
394 | + } |
|
395 | + } |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * @param string $name |
|
400 | + * @return mixed |
|
401 | + * @throws QueryException if the query could not be resolved |
|
402 | + */ |
|
403 | + public function queryNoFallback($name) { |
|
404 | + $name = $this->sanitizeName($name); |
|
405 | + |
|
406 | + if ($this->offsetExists($name)) { |
|
407 | + return parent::query($name); |
|
408 | + } else { |
|
409 | + if ($this['AppName'] === 'settings' && strpos($name, 'OC\\Settings\\') === 0) { |
|
410 | + return parent::query($name); |
|
411 | + } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
|
412 | + return parent::query($name); |
|
413 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
414 | + return parent::query($name); |
|
415 | + } |
|
416 | + } |
|
417 | + |
|
418 | + throw new QueryException('Could not resolve ' . $name . '!' . |
|
419 | + ' Class can not be instantiated', 1); |
|
420 | + } |
|
421 | 421 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @param array $urlParams |
84 | 84 | * @param ServerContainer|null $server |
85 | 85 | */ |
86 | - public function __construct($appName, $urlParams = array(), ServerContainer $server = null){ |
|
86 | + public function __construct($appName, $urlParams = array(), ServerContainer $server = null) { |
|
87 | 87 | parent::__construct(); |
88 | 88 | $this['AppName'] = $appName; |
89 | 89 | $this['urlParams'] = $urlParams; |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * Core services |
107 | 107 | */ |
108 | - $this->registerService(IOutput::class, function(){ |
|
108 | + $this->registerService(IOutput::class, function() { |
|
109 | 109 | return new Output($this->getServer()->getWebRoot()); |
110 | 110 | }); |
111 | 111 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | return $this->getServer()->getUserFolder(); |
114 | 114 | }); |
115 | 115 | |
116 | - $this->registerService(IAppData::class, function (SimpleContainer $c) { |
|
116 | + $this->registerService(IAppData::class, function(SimpleContainer $c) { |
|
117 | 117 | return $this->getServer()->getAppDataDir($c->query('AppName')); |
118 | 118 | }); |
119 | 119 | |
@@ -122,41 +122,41 @@ discard block |
||
122 | 122 | }); |
123 | 123 | |
124 | 124 | // Log wrapper |
125 | - $this->registerService(ILogger::class, function ($c) { |
|
125 | + $this->registerService(ILogger::class, function($c) { |
|
126 | 126 | return new OC\AppFramework\Logger($this->server->query(ILogger::class), $c->query('AppName')); |
127 | 127 | }); |
128 | 128 | |
129 | - $this->registerService(IServerContainer::class, function () { |
|
129 | + $this->registerService(IServerContainer::class, function() { |
|
130 | 130 | return $this->getServer(); |
131 | 131 | }); |
132 | 132 | $this->registerAlias('ServerContainer', IServerContainer::class); |
133 | 133 | |
134 | - $this->registerService(\OCP\WorkflowEngine\IManager::class, function ($c) { |
|
134 | + $this->registerService(\OCP\WorkflowEngine\IManager::class, function($c) { |
|
135 | 135 | return $c->query(Manager::class); |
136 | 136 | }); |
137 | 137 | |
138 | - $this->registerService(\OCP\AppFramework\IAppContainer::class, function ($c) { |
|
138 | + $this->registerService(\OCP\AppFramework\IAppContainer::class, function($c) { |
|
139 | 139 | return $c; |
140 | 140 | }); |
141 | 141 | |
142 | 142 | // commonly used attributes |
143 | - $this->registerService('UserId', function ($c) { |
|
143 | + $this->registerService('UserId', function($c) { |
|
144 | 144 | return $c->query(IUserSession::class)->getSession()->get('user_id'); |
145 | 145 | }); |
146 | 146 | |
147 | - $this->registerService('WebRoot', function ($c) { |
|
147 | + $this->registerService('WebRoot', function($c) { |
|
148 | 148 | return $c->query('ServerContainer')->getWebRoot(); |
149 | 149 | }); |
150 | 150 | |
151 | - $this->registerService('OC_Defaults', function ($c) { |
|
151 | + $this->registerService('OC_Defaults', function($c) { |
|
152 | 152 | return $c->getServer()->getThemingDefaults(); |
153 | 153 | }); |
154 | 154 | |
155 | - $this->registerService(IConfig::class, function ($c) { |
|
155 | + $this->registerService(IConfig::class, function($c) { |
|
156 | 156 | return $c->query(OC\GlobalScale\Config::class); |
157 | 157 | }); |
158 | 158 | |
159 | - $this->registerService('Protocol', function($c){ |
|
159 | + $this->registerService('Protocol', function($c) { |
|
160 | 160 | /** @var \OC\Server $server */ |
161 | 161 | $server = $c->query('ServerContainer'); |
162 | 162 | $protocol = $server->getRequest()->getHttpProtocol(); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * Middleware |
184 | 184 | */ |
185 | 185 | $this->registerService('MiddlewareDispatcher', function(SimpleContainer $c) { |
186 | - $server = $this->getServer(); |
|
186 | + $server = $this->getServer(); |
|
187 | 187 | |
188 | 188 | $dispatcher = new MiddlewareDispatcher(); |
189 | 189 | $dispatcher->registerMiddleware( |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | $c->query(\OC\AppFramework\Middleware\AdditionalScriptsMiddleware::class) |
279 | 279 | ); |
280 | 280 | |
281 | - foreach($this->middleWares as $middleWare) { |
|
281 | + foreach ($this->middleWares as $middleWare) { |
|
282 | 282 | $dispatcher->registerMiddleware($c->query($middleWare)); |
283 | 283 | } |
284 | 284 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | * @return mixed |
350 | 350 | */ |
351 | 351 | public function log($message, $level) { |
352 | - switch($level){ |
|
352 | + switch ($level) { |
|
353 | 353 | case 'debug': |
354 | 354 | $level = ILogger::DEBUG; |
355 | 355 | break; |
@@ -410,12 +410,12 @@ discard block |
||
410 | 410 | return parent::query($name); |
411 | 411 | } else if ($this['AppName'] === 'core' && strpos($name, 'OC\\Core\\') === 0) { |
412 | 412 | return parent::query($name); |
413 | - } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']) . '\\') === 0) { |
|
413 | + } else if (strpos($name, \OC\AppFramework\App::buildAppNamespace($this['AppName']).'\\') === 0) { |
|
414 | 414 | return parent::query($name); |
415 | 415 | } |
416 | 416 | } |
417 | 417 | |
418 | - throw new QueryException('Could not resolve ' . $name . '!' . |
|
418 | + throw new QueryException('Could not resolve '.$name.'!'. |
|
419 | 419 | ' Class can not be instantiated', 1); |
420 | 420 | } |
421 | 421 | } |