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