@@ -48,6 +48,9 @@ discard block |
||
| 48 | 48 | $this->stack = $stack; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + /** |
|
| 52 | + * @param double $time |
|
| 53 | + */ |
|
| 51 | 54 | public function end($time) { |
| 52 | 55 | $this->end = $time; |
| 53 | 56 | } |
@@ -67,7 +70,7 @@ discard block |
||
| 67 | 70 | } |
| 68 | 71 | |
| 69 | 72 | /** |
| 70 | - * @return float |
|
| 73 | + * @return integer |
|
| 71 | 74 | */ |
| 72 | 75 | public function getStart() { |
| 73 | 76 | return $this->start; |
@@ -26,65 +26,65 @@ |
||
| 26 | 26 | use OCP\Diagnostics\IQuery; |
| 27 | 27 | |
| 28 | 28 | class Query implements IQuery { |
| 29 | - private $sql; |
|
| 29 | + private $sql; |
|
| 30 | 30 | |
| 31 | - private $params; |
|
| 31 | + private $params; |
|
| 32 | 32 | |
| 33 | - private $start; |
|
| 33 | + private $start; |
|
| 34 | 34 | |
| 35 | - private $end; |
|
| 35 | + private $end; |
|
| 36 | 36 | |
| 37 | - private $stack; |
|
| 37 | + private $stack; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @param string $sql |
|
| 41 | - * @param array $params |
|
| 42 | - * @param int $start |
|
| 43 | - */ |
|
| 44 | - public function __construct($sql, $params, $start, array $stack) { |
|
| 45 | - $this->sql = $sql; |
|
| 46 | - $this->params = $params; |
|
| 47 | - $this->start = $start; |
|
| 48 | - $this->stack = $stack; |
|
| 49 | - } |
|
| 39 | + /** |
|
| 40 | + * @param string $sql |
|
| 41 | + * @param array $params |
|
| 42 | + * @param int $start |
|
| 43 | + */ |
|
| 44 | + public function __construct($sql, $params, $start, array $stack) { |
|
| 45 | + $this->sql = $sql; |
|
| 46 | + $this->params = $params; |
|
| 47 | + $this->start = $start; |
|
| 48 | + $this->stack = $stack; |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function end($time) { |
|
| 52 | - $this->end = $time; |
|
| 53 | - } |
|
| 51 | + public function end($time) { |
|
| 52 | + $this->end = $time; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @return array |
|
| 57 | - */ |
|
| 58 | - public function getParams() { |
|
| 59 | - return $this->params; |
|
| 60 | - } |
|
| 55 | + /** |
|
| 56 | + * @return array |
|
| 57 | + */ |
|
| 58 | + public function getParams() { |
|
| 59 | + return $this->params; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return string |
|
| 64 | - */ |
|
| 65 | - public function getSql() { |
|
| 66 | - return $this->sql; |
|
| 67 | - } |
|
| 62 | + /** |
|
| 63 | + * @return string |
|
| 64 | + */ |
|
| 65 | + public function getSql() { |
|
| 66 | + return $this->sql; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * @return float |
|
| 71 | - */ |
|
| 72 | - public function getStart() { |
|
| 73 | - return $this->start; |
|
| 74 | - } |
|
| 69 | + /** |
|
| 70 | + * @return float |
|
| 71 | + */ |
|
| 72 | + public function getStart() { |
|
| 73 | + return $this->start; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @return float |
|
| 78 | - */ |
|
| 79 | - public function getDuration() { |
|
| 80 | - return $this->end - $this->start; |
|
| 81 | - } |
|
| 76 | + /** |
|
| 77 | + * @return float |
|
| 78 | + */ |
|
| 79 | + public function getDuration() { |
|
| 80 | + return $this->end - $this->start; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - public function getStartTime() { |
|
| 84 | - return $this->start; |
|
| 85 | - } |
|
| 83 | + public function getStartTime() { |
|
| 84 | + return $this->start; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - public function getStacktrace() { |
|
| 88 | - return $this->stack; |
|
| 89 | - } |
|
| 87 | + public function getStacktrace() { |
|
| 88 | + return $this->stack; |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -52,8 +52,6 @@ discard block |
||
| 52 | 52 | use OC\Command\AsyncBus; |
| 53 | 53 | use OC\Contacts\ContactsMenu\ActionFactory; |
| 54 | 54 | use OC\Diagnostics\EventLogger; |
| 55 | -use OC\Diagnostics\NullEventLogger; |
|
| 56 | -use OC\Diagnostics\NullQueryLogger; |
|
| 57 | 55 | use OC\Diagnostics\QueryLogger; |
| 58 | 56 | use OC\Federation\CloudIdManager; |
| 59 | 57 | use OC\Files\Config\UserMountCache; |
@@ -98,7 +96,6 @@ discard block |
||
| 98 | 96 | use OC\Tagging\TagMapper; |
| 99 | 97 | use OC\Template\SCSSCacher; |
| 100 | 98 | use OCA\Theming\ThemingDefaults; |
| 101 | - |
|
| 102 | 99 | use OCP\App\IAppManager; |
| 103 | 100 | use OCP\Defaults; |
| 104 | 101 | use OCA\Theming\Util; |
@@ -125,1651 +125,1651 @@ |
||
| 125 | 125 | * TODO: hookup all manager classes |
| 126 | 126 | */ |
| 127 | 127 | class Server extends ServerContainer implements IServerContainer { |
| 128 | - /** @var string */ |
|
| 129 | - private $webRoot; |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @param string $webRoot |
|
| 133 | - * @param \OC\Config $config |
|
| 134 | - */ |
|
| 135 | - public function __construct($webRoot, \OC\Config $config) { |
|
| 136 | - parent::__construct(); |
|
| 137 | - $this->webRoot = $webRoot; |
|
| 138 | - |
|
| 139 | - $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
| 140 | - return $c; |
|
| 141 | - }); |
|
| 142 | - |
|
| 143 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 144 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 145 | - |
|
| 146 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 151 | - return new PreviewManager( |
|
| 152 | - $c->getConfig(), |
|
| 153 | - $c->getRootFolder(), |
|
| 154 | - $c->getAppDataDir('preview'), |
|
| 155 | - $c->getEventDispatcher(), |
|
| 156 | - $c->getSession()->get('user_id') |
|
| 157 | - ); |
|
| 158 | - }); |
|
| 159 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
| 160 | - |
|
| 161 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 162 | - return new \OC\Preview\Watcher( |
|
| 163 | - $c->getAppDataDir('preview') |
|
| 164 | - ); |
|
| 165 | - }); |
|
| 166 | - |
|
| 167 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
| 168 | - $view = new View(); |
|
| 169 | - $util = new Encryption\Util( |
|
| 170 | - $view, |
|
| 171 | - $c->getUserManager(), |
|
| 172 | - $c->getGroupManager(), |
|
| 173 | - $c->getConfig() |
|
| 174 | - ); |
|
| 175 | - return new Encryption\Manager( |
|
| 176 | - $c->getConfig(), |
|
| 177 | - $c->getLogger(), |
|
| 178 | - $c->getL10N('core'), |
|
| 179 | - new View(), |
|
| 180 | - $util, |
|
| 181 | - new ArrayCache() |
|
| 182 | - ); |
|
| 183 | - }); |
|
| 184 | - |
|
| 185 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 186 | - $util = new Encryption\Util( |
|
| 187 | - new View(), |
|
| 188 | - $c->getUserManager(), |
|
| 189 | - $c->getGroupManager(), |
|
| 190 | - $c->getConfig() |
|
| 191 | - ); |
|
| 192 | - return new Encryption\File( |
|
| 193 | - $util, |
|
| 194 | - $c->getRootFolder(), |
|
| 195 | - $c->getShareManager() |
|
| 196 | - ); |
|
| 197 | - }); |
|
| 198 | - |
|
| 199 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 200 | - $view = new View(); |
|
| 201 | - $util = new Encryption\Util( |
|
| 202 | - $view, |
|
| 203 | - $c->getUserManager(), |
|
| 204 | - $c->getGroupManager(), |
|
| 205 | - $c->getConfig() |
|
| 206 | - ); |
|
| 207 | - |
|
| 208 | - return new Encryption\Keys\Storage($view, $util); |
|
| 209 | - }); |
|
| 210 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 211 | - return new TagMapper($c->getDatabaseConnection()); |
|
| 212 | - }); |
|
| 213 | - |
|
| 214 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 215 | - $tagMapper = $c->query('TagMapper'); |
|
| 216 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
| 217 | - }); |
|
| 218 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
| 219 | - |
|
| 220 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 221 | - $config = $c->getConfig(); |
|
| 222 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
| 223 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
| 224 | - $factory = new $factoryClass($this); |
|
| 225 | - return $factory; |
|
| 226 | - }); |
|
| 227 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 228 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 229 | - }); |
|
| 230 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
| 231 | - |
|
| 232 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 233 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 234 | - }); |
|
| 235 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 236 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 237 | - $view = new View(); |
|
| 238 | - $root = new Root( |
|
| 239 | - $manager, |
|
| 240 | - $view, |
|
| 241 | - null, |
|
| 242 | - $c->getUserMountCache(), |
|
| 243 | - $this->getLogger(), |
|
| 244 | - $this->getUserManager() |
|
| 245 | - ); |
|
| 246 | - $connector = new HookConnector($root, $view); |
|
| 247 | - $connector->viewToNode(); |
|
| 248 | - |
|
| 249 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 250 | - $previewConnector->connectWatcher(); |
|
| 251 | - |
|
| 252 | - return $root; |
|
| 253 | - }); |
|
| 254 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
| 255 | - |
|
| 256 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
| 257 | - return new LazyRoot(function() use ($c) { |
|
| 258 | - return $c->query('RootFolder'); |
|
| 259 | - }); |
|
| 260 | - }); |
|
| 261 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
| 262 | - |
|
| 263 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
| 264 | - $config = $c->getConfig(); |
|
| 265 | - return new \OC\User\Manager($config); |
|
| 266 | - }); |
|
| 267 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
| 268 | - |
|
| 269 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 270 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
| 271 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 272 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
| 273 | - }); |
|
| 274 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 275 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
| 276 | - }); |
|
| 277 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 278 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
| 279 | - }); |
|
| 280 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 281 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
| 282 | - }); |
|
| 283 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 284 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 285 | - }); |
|
| 286 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 287 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 288 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 289 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 290 | - }); |
|
| 291 | - return $groupManager; |
|
| 292 | - }); |
|
| 293 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 294 | - |
|
| 295 | - $this->registerService(Store::class, function(Server $c) { |
|
| 296 | - $session = $c->getSession(); |
|
| 297 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 298 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
| 299 | - } else { |
|
| 300 | - $tokenProvider = null; |
|
| 301 | - } |
|
| 302 | - $logger = $c->getLogger(); |
|
| 303 | - return new Store($session, $logger, $tokenProvider); |
|
| 304 | - }); |
|
| 305 | - $this->registerAlias(IStore::class, Store::class); |
|
| 306 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
| 307 | - $dbConnection = $c->getDatabaseConnection(); |
|
| 308 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 309 | - }); |
|
| 310 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
| 311 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
| 312 | - $crypto = $c->getCrypto(); |
|
| 313 | - $config = $c->getConfig(); |
|
| 314 | - $logger = $c->getLogger(); |
|
| 315 | - $timeFactory = new TimeFactory(); |
|
| 316 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
| 317 | - }); |
|
| 318 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
| 319 | - |
|
| 320 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 321 | - $manager = $c->getUserManager(); |
|
| 322 | - $session = new \OC\Session\Memory(''); |
|
| 323 | - $timeFactory = new TimeFactory(); |
|
| 324 | - // Token providers might require a working database. This code |
|
| 325 | - // might however be called when ownCloud is not yet setup. |
|
| 326 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 327 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
| 328 | - } else { |
|
| 329 | - $defaultTokenProvider = null; |
|
| 330 | - } |
|
| 331 | - |
|
| 332 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
| 333 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 334 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 335 | - }); |
|
| 336 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 337 | - /** @var $user \OC\User\User */ |
|
| 338 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
| 339 | - }); |
|
| 340 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
| 341 | - /** @var $user \OC\User\User */ |
|
| 342 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
| 343 | - }); |
|
| 344 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 345 | - /** @var $user \OC\User\User */ |
|
| 346 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
| 347 | - }); |
|
| 348 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 349 | - /** @var $user \OC\User\User */ |
|
| 350 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 351 | - }); |
|
| 352 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 353 | - /** @var $user \OC\User\User */ |
|
| 354 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 355 | - }); |
|
| 356 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 357 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 358 | - }); |
|
| 359 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 360 | - /** @var $user \OC\User\User */ |
|
| 361 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 362 | - }); |
|
| 363 | - $userSession->listen('\OC\User', 'logout', function () { |
|
| 364 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
| 365 | - }); |
|
| 366 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 367 | - /** @var $user \OC\User\User */ |
|
| 368 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
| 369 | - }); |
|
| 370 | - return $userSession; |
|
| 371 | - }); |
|
| 372 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
| 373 | - |
|
| 374 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 375 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
| 376 | - }); |
|
| 377 | - |
|
| 378 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
| 379 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
| 380 | - |
|
| 381 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 382 | - return new \OC\AllConfig( |
|
| 383 | - $c->getSystemConfig() |
|
| 384 | - ); |
|
| 385 | - }); |
|
| 386 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
| 387 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 388 | - |
|
| 389 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 390 | - return new \OC\SystemConfig($config); |
|
| 391 | - }); |
|
| 392 | - |
|
| 393 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 394 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 395 | - }); |
|
| 396 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
| 397 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
| 398 | - |
|
| 399 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 400 | - return new \OC\L10N\Factory( |
|
| 401 | - $c->getConfig(), |
|
| 402 | - $c->getRequest(), |
|
| 403 | - $c->getUserSession(), |
|
| 404 | - \OC::$SERVERROOT |
|
| 405 | - ); |
|
| 406 | - }); |
|
| 407 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
| 408 | - |
|
| 409 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 410 | - $config = $c->getConfig(); |
|
| 411 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 412 | - return new \OC\URLGenerator( |
|
| 413 | - $config, |
|
| 414 | - $cacheFactory |
|
| 415 | - ); |
|
| 416 | - }); |
|
| 417 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
| 418 | - |
|
| 419 | - $this->registerService('AppHelper', function ($c) { |
|
| 420 | - return new \OC\AppHelper(); |
|
| 421 | - }); |
|
| 422 | - $this->registerService('AppFetcher', function ($c) { |
|
| 423 | - return new AppFetcher( |
|
| 424 | - $this->getAppDataDir('appstore'), |
|
| 425 | - $this->getHTTPClientService(), |
|
| 426 | - $this->query(TimeFactory::class), |
|
| 427 | - $this->getConfig() |
|
| 428 | - ); |
|
| 429 | - }); |
|
| 430 | - $this->registerService('CategoryFetcher', function ($c) { |
|
| 431 | - return new CategoryFetcher( |
|
| 432 | - $this->getAppDataDir('appstore'), |
|
| 433 | - $this->getHTTPClientService(), |
|
| 434 | - $this->query(TimeFactory::class), |
|
| 435 | - $this->getConfig() |
|
| 436 | - ); |
|
| 437 | - }); |
|
| 438 | - |
|
| 439 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 440 | - return new Cache\File(); |
|
| 441 | - }); |
|
| 442 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
| 443 | - |
|
| 444 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 445 | - $config = $c->getConfig(); |
|
| 446 | - |
|
| 447 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 448 | - $v = \OC_App::getAppVersions(); |
|
| 449 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
| 450 | - $version = implode(',', $v); |
|
| 451 | - $instanceId = \OC_Util::getInstanceId(); |
|
| 452 | - $path = \OC::$SERVERROOT; |
|
| 453 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
| 454 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 455 | - $config->getSystemValue('memcache.local', null), |
|
| 456 | - $config->getSystemValue('memcache.distributed', null), |
|
| 457 | - $config->getSystemValue('memcache.locking', null) |
|
| 458 | - ); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 462 | - '\\OC\\Memcache\\ArrayCache', |
|
| 463 | - '\\OC\\Memcache\\ArrayCache', |
|
| 464 | - '\\OC\\Memcache\\ArrayCache' |
|
| 465 | - ); |
|
| 466 | - }); |
|
| 467 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
| 468 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 469 | - |
|
| 470 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 471 | - $systemConfig = $c->getSystemConfig(); |
|
| 472 | - return new RedisFactory($systemConfig); |
|
| 473 | - }); |
|
| 474 | - |
|
| 475 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 476 | - return new \OC\Activity\Manager( |
|
| 477 | - $c->getRequest(), |
|
| 478 | - $c->getUserSession(), |
|
| 479 | - $c->getConfig(), |
|
| 480 | - $c->query(IValidator::class) |
|
| 481 | - ); |
|
| 482 | - }); |
|
| 483 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 484 | - |
|
| 485 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 486 | - return new \OC\Activity\EventMerger( |
|
| 487 | - $c->getL10N('lib') |
|
| 488 | - ); |
|
| 489 | - }); |
|
| 490 | - $this->registerAlias(IValidator::class, Validator::class); |
|
| 491 | - |
|
| 492 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 493 | - return new AvatarManager( |
|
| 494 | - $c->getUserManager(), |
|
| 495 | - $c->getAppDataDir('avatar'), |
|
| 496 | - $c->getL10N('lib'), |
|
| 497 | - $c->getLogger(), |
|
| 498 | - $c->getConfig() |
|
| 499 | - ); |
|
| 500 | - }); |
|
| 501 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
| 502 | - |
|
| 503 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 504 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
| 505 | - $logger = Log::getLogClass($logType); |
|
| 506 | - call_user_func(array($logger, 'init')); |
|
| 507 | - |
|
| 508 | - return new Log($logger); |
|
| 509 | - }); |
|
| 510 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
| 511 | - |
|
| 512 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 513 | - $config = $c->getConfig(); |
|
| 514 | - return new \OC\BackgroundJob\JobList( |
|
| 515 | - $c->getDatabaseConnection(), |
|
| 516 | - $config, |
|
| 517 | - new TimeFactory() |
|
| 518 | - ); |
|
| 519 | - }); |
|
| 520 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
| 521 | - |
|
| 522 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 523 | - $cacheFactory = $c->getMemCacheFactory(); |
|
| 524 | - $logger = $c->getLogger(); |
|
| 525 | - if ($cacheFactory->isAvailable()) { |
|
| 526 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
| 527 | - } else { |
|
| 528 | - $router = new \OC\Route\Router($logger); |
|
| 529 | - } |
|
| 530 | - return $router; |
|
| 531 | - }); |
|
| 532 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
| 533 | - |
|
| 534 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 535 | - return new Search(); |
|
| 536 | - }); |
|
| 537 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
| 538 | - |
|
| 539 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
| 540 | - return new \OC\Security\RateLimiting\Limiter( |
|
| 541 | - $this->getUserSession(), |
|
| 542 | - $this->getRequest(), |
|
| 543 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
| 544 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
| 545 | - ); |
|
| 546 | - }); |
|
| 547 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
| 548 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 549 | - $this->getMemCacheFactory(), |
|
| 550 | - new \OC\AppFramework\Utility\TimeFactory() |
|
| 551 | - ); |
|
| 552 | - }); |
|
| 553 | - |
|
| 554 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 555 | - return new SecureRandom(); |
|
| 556 | - }); |
|
| 557 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 558 | - |
|
| 559 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 560 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 561 | - }); |
|
| 562 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
| 563 | - |
|
| 564 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 565 | - return new Hasher($c->getConfig()); |
|
| 566 | - }); |
|
| 567 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
| 568 | - |
|
| 569 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 570 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 571 | - }); |
|
| 572 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
| 573 | - |
|
| 574 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 575 | - $systemConfig = $c->getSystemConfig(); |
|
| 576 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 577 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 578 | - if (!$factory->isValidType($type)) { |
|
| 579 | - throw new \OC\DatabaseException('Invalid database type'); |
|
| 580 | - } |
|
| 581 | - $connectionParams = $factory->createConnectionParams(); |
|
| 582 | - $connection = $factory->getConnection($type, $connectionParams); |
|
| 583 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 584 | - return $connection; |
|
| 585 | - }); |
|
| 586 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
| 587 | - |
|
| 588 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
| 589 | - $config = $c->getConfig(); |
|
| 590 | - return new HTTPHelper( |
|
| 591 | - $config, |
|
| 592 | - $c->getHTTPClientService() |
|
| 593 | - ); |
|
| 594 | - }); |
|
| 595 | - |
|
| 596 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 597 | - $user = \OC_User::getUser(); |
|
| 598 | - $uid = $user ? $user : null; |
|
| 599 | - return new ClientService( |
|
| 600 | - $c->getConfig(), |
|
| 601 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
| 602 | - ); |
|
| 603 | - }); |
|
| 604 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
| 605 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 606 | - $eventLogger = new EventLogger(); |
|
| 607 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 608 | - // In debug mode, module is being activated by default |
|
| 609 | - $eventLogger->activate(); |
|
| 610 | - } |
|
| 611 | - return $eventLogger; |
|
| 612 | - }); |
|
| 613 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
| 614 | - |
|
| 615 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 616 | - $queryLogger = new QueryLogger(); |
|
| 617 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 618 | - // In debug mode, module is being activated by default |
|
| 619 | - $queryLogger->activate(); |
|
| 620 | - } |
|
| 621 | - return $queryLogger; |
|
| 622 | - }); |
|
| 623 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
| 624 | - |
|
| 625 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 626 | - return new TempManager( |
|
| 627 | - $c->getLogger(), |
|
| 628 | - $c->getConfig() |
|
| 629 | - ); |
|
| 630 | - }); |
|
| 631 | - $this->registerAlias('TempManager', TempManager::class); |
|
| 632 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 633 | - |
|
| 634 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 635 | - return new \OC\App\AppManager( |
|
| 636 | - $c->getUserSession(), |
|
| 637 | - $c->getAppConfig(), |
|
| 638 | - $c->getGroupManager(), |
|
| 639 | - $c->getMemCacheFactory(), |
|
| 640 | - $c->getEventDispatcher() |
|
| 641 | - ); |
|
| 642 | - }); |
|
| 643 | - $this->registerAlias('AppManager', AppManager::class); |
|
| 644 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 645 | - |
|
| 646 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 647 | - return new DateTimeZone( |
|
| 648 | - $c->getConfig(), |
|
| 649 | - $c->getSession() |
|
| 650 | - ); |
|
| 651 | - }); |
|
| 652 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
| 653 | - |
|
| 654 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 655 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 656 | - |
|
| 657 | - return new DateTimeFormatter( |
|
| 658 | - $c->getDateTimeZone()->getTimeZone(), |
|
| 659 | - $c->getL10N('lib', $language) |
|
| 660 | - ); |
|
| 661 | - }); |
|
| 662 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
| 663 | - |
|
| 664 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 665 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 666 | - $listener = new UserMountCacheListener($mountCache); |
|
| 667 | - $listener->listen($c->getUserManager()); |
|
| 668 | - return $mountCache; |
|
| 669 | - }); |
|
| 670 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
| 671 | - |
|
| 672 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 673 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
| 674 | - $mountCache = $c->query('UserMountCache'); |
|
| 675 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 676 | - |
|
| 677 | - // builtin providers |
|
| 678 | - |
|
| 679 | - $config = $c->getConfig(); |
|
| 680 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
| 681 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 682 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 683 | - |
|
| 684 | - return $manager; |
|
| 685 | - }); |
|
| 686 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
| 687 | - |
|
| 688 | - $this->registerService('IniWrapper', function ($c) { |
|
| 689 | - return new IniGetWrapper(); |
|
| 690 | - }); |
|
| 691 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 692 | - $jobList = $c->getJobList(); |
|
| 693 | - return new AsyncBus($jobList); |
|
| 694 | - }); |
|
| 695 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 696 | - return new TrustedDomainHelper($this->getConfig()); |
|
| 697 | - }); |
|
| 698 | - $this->registerService('Throttler', function(Server $c) { |
|
| 699 | - return new Throttler( |
|
| 700 | - $c->getDatabaseConnection(), |
|
| 701 | - new TimeFactory(), |
|
| 702 | - $c->getLogger(), |
|
| 703 | - $c->getConfig() |
|
| 704 | - ); |
|
| 705 | - }); |
|
| 706 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 707 | - // IConfig and IAppManager requires a working database. This code |
|
| 708 | - // might however be called when ownCloud is not yet setup. |
|
| 709 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 710 | - $config = $c->getConfig(); |
|
| 711 | - $appManager = $c->getAppManager(); |
|
| 712 | - } else { |
|
| 713 | - $config = null; |
|
| 714 | - $appManager = null; |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - return new Checker( |
|
| 718 | - new EnvironmentHelper(), |
|
| 719 | - new FileAccessHelper(), |
|
| 720 | - new AppLocator(), |
|
| 721 | - $config, |
|
| 722 | - $c->getMemCacheFactory(), |
|
| 723 | - $appManager, |
|
| 724 | - $c->getTempManager() |
|
| 725 | - ); |
|
| 726 | - }); |
|
| 727 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 728 | - if (isset($this['urlParams'])) { |
|
| 729 | - $urlParams = $this['urlParams']; |
|
| 730 | - } else { |
|
| 731 | - $urlParams = []; |
|
| 732 | - } |
|
| 733 | - |
|
| 734 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 735 | - && in_array('fakeinput', stream_get_wrappers()) |
|
| 736 | - ) { |
|
| 737 | - $stream = 'fakeinput://data'; |
|
| 738 | - } else { |
|
| 739 | - $stream = 'php://input'; |
|
| 740 | - } |
|
| 741 | - |
|
| 742 | - return new Request( |
|
| 743 | - [ |
|
| 744 | - 'get' => $_GET, |
|
| 745 | - 'post' => $_POST, |
|
| 746 | - 'files' => $_FILES, |
|
| 747 | - 'server' => $_SERVER, |
|
| 748 | - 'env' => $_ENV, |
|
| 749 | - 'cookies' => $_COOKIE, |
|
| 750 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 751 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 752 | - : null, |
|
| 753 | - 'urlParams' => $urlParams, |
|
| 754 | - ], |
|
| 755 | - $this->getSecureRandom(), |
|
| 756 | - $this->getConfig(), |
|
| 757 | - $this->getCsrfTokenManager(), |
|
| 758 | - $stream |
|
| 759 | - ); |
|
| 760 | - }); |
|
| 761 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
| 762 | - |
|
| 763 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 764 | - return new Mailer( |
|
| 765 | - $c->getConfig(), |
|
| 766 | - $c->getLogger(), |
|
| 767 | - $c->query(Defaults::class), |
|
| 768 | - $c->getURLGenerator(), |
|
| 769 | - $c->getL10N('lib') |
|
| 770 | - ); |
|
| 771 | - }); |
|
| 772 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
| 773 | - |
|
| 774 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
| 775 | - $config = $c->getConfig(); |
|
| 776 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 777 | - if(is_null($factoryClass)) { |
|
| 778 | - throw new \Exception('ldapProviderFactory not set'); |
|
| 779 | - } |
|
| 780 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 781 | - $factory = new $factoryClass($this); |
|
| 782 | - return $factory->getLDAPProvider(); |
|
| 783 | - }); |
|
| 784 | - $this->registerService('LockingProvider', function (Server $c) { |
|
| 785 | - $ini = $c->getIniWrapper(); |
|
| 786 | - $config = $c->getConfig(); |
|
| 787 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 788 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 789 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 790 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
| 791 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
| 792 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 793 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
| 794 | - } |
|
| 795 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
| 796 | - } |
|
| 797 | - return new NoopLockingProvider(); |
|
| 798 | - }); |
|
| 799 | - |
|
| 800 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 801 | - return new \OC\Files\Mount\Manager(); |
|
| 802 | - }); |
|
| 803 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
| 804 | - |
|
| 805 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 806 | - return new \OC\Files\Type\Detection( |
|
| 807 | - $c->getURLGenerator(), |
|
| 808 | - \OC::$configDir, |
|
| 809 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 810 | - ); |
|
| 811 | - }); |
|
| 812 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
| 813 | - |
|
| 814 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 815 | - return new \OC\Files\Type\Loader( |
|
| 816 | - $c->getDatabaseConnection() |
|
| 817 | - ); |
|
| 818 | - }); |
|
| 819 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
| 820 | - |
|
| 821 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 822 | - return new Manager( |
|
| 823 | - $c->query(IValidator::class) |
|
| 824 | - ); |
|
| 825 | - }); |
|
| 826 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 827 | - |
|
| 828 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 829 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
| 830 | - $manager->registerCapability(function () use ($c) { |
|
| 831 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 832 | - }); |
|
| 833 | - return $manager; |
|
| 834 | - }); |
|
| 835 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
| 836 | - |
|
| 837 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
| 838 | - $config = $c->getConfig(); |
|
| 839 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
| 840 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 841 | - $factory = new $factoryClass($this); |
|
| 842 | - return $factory->getManager(); |
|
| 843 | - }); |
|
| 844 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
| 845 | - |
|
| 846 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
| 847 | - /* |
|
| 128 | + /** @var string */ |
|
| 129 | + private $webRoot; |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @param string $webRoot |
|
| 133 | + * @param \OC\Config $config |
|
| 134 | + */ |
|
| 135 | + public function __construct($webRoot, \OC\Config $config) { |
|
| 136 | + parent::__construct(); |
|
| 137 | + $this->webRoot = $webRoot; |
|
| 138 | + |
|
| 139 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
| 140 | + return $c; |
|
| 141 | + }); |
|
| 142 | + |
|
| 143 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
| 144 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
| 145 | + |
|
| 146 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 151 | + return new PreviewManager( |
|
| 152 | + $c->getConfig(), |
|
| 153 | + $c->getRootFolder(), |
|
| 154 | + $c->getAppDataDir('preview'), |
|
| 155 | + $c->getEventDispatcher(), |
|
| 156 | + $c->getSession()->get('user_id') |
|
| 157 | + ); |
|
| 158 | + }); |
|
| 159 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
| 160 | + |
|
| 161 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 162 | + return new \OC\Preview\Watcher( |
|
| 163 | + $c->getAppDataDir('preview') |
|
| 164 | + ); |
|
| 165 | + }); |
|
| 166 | + |
|
| 167 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
| 168 | + $view = new View(); |
|
| 169 | + $util = new Encryption\Util( |
|
| 170 | + $view, |
|
| 171 | + $c->getUserManager(), |
|
| 172 | + $c->getGroupManager(), |
|
| 173 | + $c->getConfig() |
|
| 174 | + ); |
|
| 175 | + return new Encryption\Manager( |
|
| 176 | + $c->getConfig(), |
|
| 177 | + $c->getLogger(), |
|
| 178 | + $c->getL10N('core'), |
|
| 179 | + new View(), |
|
| 180 | + $util, |
|
| 181 | + new ArrayCache() |
|
| 182 | + ); |
|
| 183 | + }); |
|
| 184 | + |
|
| 185 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 186 | + $util = new Encryption\Util( |
|
| 187 | + new View(), |
|
| 188 | + $c->getUserManager(), |
|
| 189 | + $c->getGroupManager(), |
|
| 190 | + $c->getConfig() |
|
| 191 | + ); |
|
| 192 | + return new Encryption\File( |
|
| 193 | + $util, |
|
| 194 | + $c->getRootFolder(), |
|
| 195 | + $c->getShareManager() |
|
| 196 | + ); |
|
| 197 | + }); |
|
| 198 | + |
|
| 199 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 200 | + $view = new View(); |
|
| 201 | + $util = new Encryption\Util( |
|
| 202 | + $view, |
|
| 203 | + $c->getUserManager(), |
|
| 204 | + $c->getGroupManager(), |
|
| 205 | + $c->getConfig() |
|
| 206 | + ); |
|
| 207 | + |
|
| 208 | + return new Encryption\Keys\Storage($view, $util); |
|
| 209 | + }); |
|
| 210 | + $this->registerService('TagMapper', function (Server $c) { |
|
| 211 | + return new TagMapper($c->getDatabaseConnection()); |
|
| 212 | + }); |
|
| 213 | + |
|
| 214 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 215 | + $tagMapper = $c->query('TagMapper'); |
|
| 216 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
| 217 | + }); |
|
| 218 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
| 219 | + |
|
| 220 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 221 | + $config = $c->getConfig(); |
|
| 222 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
| 223 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
| 224 | + $factory = new $factoryClass($this); |
|
| 225 | + return $factory; |
|
| 226 | + }); |
|
| 227 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 228 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
| 229 | + }); |
|
| 230 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
| 231 | + |
|
| 232 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 233 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
| 234 | + }); |
|
| 235 | + $this->registerService('RootFolder', function (Server $c) { |
|
| 236 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
| 237 | + $view = new View(); |
|
| 238 | + $root = new Root( |
|
| 239 | + $manager, |
|
| 240 | + $view, |
|
| 241 | + null, |
|
| 242 | + $c->getUserMountCache(), |
|
| 243 | + $this->getLogger(), |
|
| 244 | + $this->getUserManager() |
|
| 245 | + ); |
|
| 246 | + $connector = new HookConnector($root, $view); |
|
| 247 | + $connector->viewToNode(); |
|
| 248 | + |
|
| 249 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
| 250 | + $previewConnector->connectWatcher(); |
|
| 251 | + |
|
| 252 | + return $root; |
|
| 253 | + }); |
|
| 254 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
| 255 | + |
|
| 256 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
| 257 | + return new LazyRoot(function() use ($c) { |
|
| 258 | + return $c->query('RootFolder'); |
|
| 259 | + }); |
|
| 260 | + }); |
|
| 261 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
| 262 | + |
|
| 263 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
| 264 | + $config = $c->getConfig(); |
|
| 265 | + return new \OC\User\Manager($config); |
|
| 266 | + }); |
|
| 267 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
| 268 | + |
|
| 269 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 270 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
| 271 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 272 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
| 273 | + }); |
|
| 274 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 275 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
| 276 | + }); |
|
| 277 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 278 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
| 279 | + }); |
|
| 280 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 281 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
| 282 | + }); |
|
| 283 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 284 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 285 | + }); |
|
| 286 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 287 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 288 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
| 289 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
| 290 | + }); |
|
| 291 | + return $groupManager; |
|
| 292 | + }); |
|
| 293 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
| 294 | + |
|
| 295 | + $this->registerService(Store::class, function(Server $c) { |
|
| 296 | + $session = $c->getSession(); |
|
| 297 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 298 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
| 299 | + } else { |
|
| 300 | + $tokenProvider = null; |
|
| 301 | + } |
|
| 302 | + $logger = $c->getLogger(); |
|
| 303 | + return new Store($session, $logger, $tokenProvider); |
|
| 304 | + }); |
|
| 305 | + $this->registerAlias(IStore::class, Store::class); |
|
| 306 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
| 307 | + $dbConnection = $c->getDatabaseConnection(); |
|
| 308 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
| 309 | + }); |
|
| 310 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
| 311 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
| 312 | + $crypto = $c->getCrypto(); |
|
| 313 | + $config = $c->getConfig(); |
|
| 314 | + $logger = $c->getLogger(); |
|
| 315 | + $timeFactory = new TimeFactory(); |
|
| 316 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
| 317 | + }); |
|
| 318 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
| 319 | + |
|
| 320 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 321 | + $manager = $c->getUserManager(); |
|
| 322 | + $session = new \OC\Session\Memory(''); |
|
| 323 | + $timeFactory = new TimeFactory(); |
|
| 324 | + // Token providers might require a working database. This code |
|
| 325 | + // might however be called when ownCloud is not yet setup. |
|
| 326 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 327 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
| 328 | + } else { |
|
| 329 | + $defaultTokenProvider = null; |
|
| 330 | + } |
|
| 331 | + |
|
| 332 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
| 333 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 334 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 335 | + }); |
|
| 336 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 337 | + /** @var $user \OC\User\User */ |
|
| 338 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
| 339 | + }); |
|
| 340 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
| 341 | + /** @var $user \OC\User\User */ |
|
| 342 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
| 343 | + }); |
|
| 344 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 345 | + /** @var $user \OC\User\User */ |
|
| 346 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
| 347 | + }); |
|
| 348 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 349 | + /** @var $user \OC\User\User */ |
|
| 350 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 351 | + }); |
|
| 352 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 353 | + /** @var $user \OC\User\User */ |
|
| 354 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
| 355 | + }); |
|
| 356 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 357 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
| 358 | + }); |
|
| 359 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 360 | + /** @var $user \OC\User\User */ |
|
| 361 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
| 362 | + }); |
|
| 363 | + $userSession->listen('\OC\User', 'logout', function () { |
|
| 364 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
| 365 | + }); |
|
| 366 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 367 | + /** @var $user \OC\User\User */ |
|
| 368 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
| 369 | + }); |
|
| 370 | + return $userSession; |
|
| 371 | + }); |
|
| 372 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
| 373 | + |
|
| 374 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 375 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
| 376 | + }); |
|
| 377 | + |
|
| 378 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
| 379 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
| 380 | + |
|
| 381 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 382 | + return new \OC\AllConfig( |
|
| 383 | + $c->getSystemConfig() |
|
| 384 | + ); |
|
| 385 | + }); |
|
| 386 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
| 387 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
| 388 | + |
|
| 389 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 390 | + return new \OC\SystemConfig($config); |
|
| 391 | + }); |
|
| 392 | + |
|
| 393 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 394 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
| 395 | + }); |
|
| 396 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
| 397 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
| 398 | + |
|
| 399 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 400 | + return new \OC\L10N\Factory( |
|
| 401 | + $c->getConfig(), |
|
| 402 | + $c->getRequest(), |
|
| 403 | + $c->getUserSession(), |
|
| 404 | + \OC::$SERVERROOT |
|
| 405 | + ); |
|
| 406 | + }); |
|
| 407 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
| 408 | + |
|
| 409 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 410 | + $config = $c->getConfig(); |
|
| 411 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 412 | + return new \OC\URLGenerator( |
|
| 413 | + $config, |
|
| 414 | + $cacheFactory |
|
| 415 | + ); |
|
| 416 | + }); |
|
| 417 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
| 418 | + |
|
| 419 | + $this->registerService('AppHelper', function ($c) { |
|
| 420 | + return new \OC\AppHelper(); |
|
| 421 | + }); |
|
| 422 | + $this->registerService('AppFetcher', function ($c) { |
|
| 423 | + return new AppFetcher( |
|
| 424 | + $this->getAppDataDir('appstore'), |
|
| 425 | + $this->getHTTPClientService(), |
|
| 426 | + $this->query(TimeFactory::class), |
|
| 427 | + $this->getConfig() |
|
| 428 | + ); |
|
| 429 | + }); |
|
| 430 | + $this->registerService('CategoryFetcher', function ($c) { |
|
| 431 | + return new CategoryFetcher( |
|
| 432 | + $this->getAppDataDir('appstore'), |
|
| 433 | + $this->getHTTPClientService(), |
|
| 434 | + $this->query(TimeFactory::class), |
|
| 435 | + $this->getConfig() |
|
| 436 | + ); |
|
| 437 | + }); |
|
| 438 | + |
|
| 439 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 440 | + return new Cache\File(); |
|
| 441 | + }); |
|
| 442 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
| 443 | + |
|
| 444 | + $this->registerService(Factory::class, function (Server $c) { |
|
| 445 | + $config = $c->getConfig(); |
|
| 446 | + |
|
| 447 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 448 | + $v = \OC_App::getAppVersions(); |
|
| 449 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
| 450 | + $version = implode(',', $v); |
|
| 451 | + $instanceId = \OC_Util::getInstanceId(); |
|
| 452 | + $path = \OC::$SERVERROOT; |
|
| 453 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
| 454 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
| 455 | + $config->getSystemValue('memcache.local', null), |
|
| 456 | + $config->getSystemValue('memcache.distributed', null), |
|
| 457 | + $config->getSystemValue('memcache.locking', null) |
|
| 458 | + ); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
| 462 | + '\\OC\\Memcache\\ArrayCache', |
|
| 463 | + '\\OC\\Memcache\\ArrayCache', |
|
| 464 | + '\\OC\\Memcache\\ArrayCache' |
|
| 465 | + ); |
|
| 466 | + }); |
|
| 467 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
| 468 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
| 469 | + |
|
| 470 | + $this->registerService('RedisFactory', function (Server $c) { |
|
| 471 | + $systemConfig = $c->getSystemConfig(); |
|
| 472 | + return new RedisFactory($systemConfig); |
|
| 473 | + }); |
|
| 474 | + |
|
| 475 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 476 | + return new \OC\Activity\Manager( |
|
| 477 | + $c->getRequest(), |
|
| 478 | + $c->getUserSession(), |
|
| 479 | + $c->getConfig(), |
|
| 480 | + $c->query(IValidator::class) |
|
| 481 | + ); |
|
| 482 | + }); |
|
| 483 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
| 484 | + |
|
| 485 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 486 | + return new \OC\Activity\EventMerger( |
|
| 487 | + $c->getL10N('lib') |
|
| 488 | + ); |
|
| 489 | + }); |
|
| 490 | + $this->registerAlias(IValidator::class, Validator::class); |
|
| 491 | + |
|
| 492 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 493 | + return new AvatarManager( |
|
| 494 | + $c->getUserManager(), |
|
| 495 | + $c->getAppDataDir('avatar'), |
|
| 496 | + $c->getL10N('lib'), |
|
| 497 | + $c->getLogger(), |
|
| 498 | + $c->getConfig() |
|
| 499 | + ); |
|
| 500 | + }); |
|
| 501 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
| 502 | + |
|
| 503 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 504 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
| 505 | + $logger = Log::getLogClass($logType); |
|
| 506 | + call_user_func(array($logger, 'init')); |
|
| 507 | + |
|
| 508 | + return new Log($logger); |
|
| 509 | + }); |
|
| 510 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
| 511 | + |
|
| 512 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 513 | + $config = $c->getConfig(); |
|
| 514 | + return new \OC\BackgroundJob\JobList( |
|
| 515 | + $c->getDatabaseConnection(), |
|
| 516 | + $config, |
|
| 517 | + new TimeFactory() |
|
| 518 | + ); |
|
| 519 | + }); |
|
| 520 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
| 521 | + |
|
| 522 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 523 | + $cacheFactory = $c->getMemCacheFactory(); |
|
| 524 | + $logger = $c->getLogger(); |
|
| 525 | + if ($cacheFactory->isAvailable()) { |
|
| 526 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
| 527 | + } else { |
|
| 528 | + $router = new \OC\Route\Router($logger); |
|
| 529 | + } |
|
| 530 | + return $router; |
|
| 531 | + }); |
|
| 532 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
| 533 | + |
|
| 534 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 535 | + return new Search(); |
|
| 536 | + }); |
|
| 537 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
| 538 | + |
|
| 539 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
| 540 | + return new \OC\Security\RateLimiting\Limiter( |
|
| 541 | + $this->getUserSession(), |
|
| 542 | + $this->getRequest(), |
|
| 543 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
| 544 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
| 545 | + ); |
|
| 546 | + }); |
|
| 547 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
| 548 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
| 549 | + $this->getMemCacheFactory(), |
|
| 550 | + new \OC\AppFramework\Utility\TimeFactory() |
|
| 551 | + ); |
|
| 552 | + }); |
|
| 553 | + |
|
| 554 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 555 | + return new SecureRandom(); |
|
| 556 | + }); |
|
| 557 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
| 558 | + |
|
| 559 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 560 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
| 561 | + }); |
|
| 562 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
| 563 | + |
|
| 564 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 565 | + return new Hasher($c->getConfig()); |
|
| 566 | + }); |
|
| 567 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
| 568 | + |
|
| 569 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 570 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
| 571 | + }); |
|
| 572 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
| 573 | + |
|
| 574 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 575 | + $systemConfig = $c->getSystemConfig(); |
|
| 576 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
| 577 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
| 578 | + if (!$factory->isValidType($type)) { |
|
| 579 | + throw new \OC\DatabaseException('Invalid database type'); |
|
| 580 | + } |
|
| 581 | + $connectionParams = $factory->createConnectionParams(); |
|
| 582 | + $connection = $factory->getConnection($type, $connectionParams); |
|
| 583 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
| 584 | + return $connection; |
|
| 585 | + }); |
|
| 586 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
| 587 | + |
|
| 588 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
| 589 | + $config = $c->getConfig(); |
|
| 590 | + return new HTTPHelper( |
|
| 591 | + $config, |
|
| 592 | + $c->getHTTPClientService() |
|
| 593 | + ); |
|
| 594 | + }); |
|
| 595 | + |
|
| 596 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 597 | + $user = \OC_User::getUser(); |
|
| 598 | + $uid = $user ? $user : null; |
|
| 599 | + return new ClientService( |
|
| 600 | + $c->getConfig(), |
|
| 601 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
| 602 | + ); |
|
| 603 | + }); |
|
| 604 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
| 605 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 606 | + $eventLogger = new EventLogger(); |
|
| 607 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 608 | + // In debug mode, module is being activated by default |
|
| 609 | + $eventLogger->activate(); |
|
| 610 | + } |
|
| 611 | + return $eventLogger; |
|
| 612 | + }); |
|
| 613 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
| 614 | + |
|
| 615 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 616 | + $queryLogger = new QueryLogger(); |
|
| 617 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
| 618 | + // In debug mode, module is being activated by default |
|
| 619 | + $queryLogger->activate(); |
|
| 620 | + } |
|
| 621 | + return $queryLogger; |
|
| 622 | + }); |
|
| 623 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
| 624 | + |
|
| 625 | + $this->registerService(TempManager::class, function (Server $c) { |
|
| 626 | + return new TempManager( |
|
| 627 | + $c->getLogger(), |
|
| 628 | + $c->getConfig() |
|
| 629 | + ); |
|
| 630 | + }); |
|
| 631 | + $this->registerAlias('TempManager', TempManager::class); |
|
| 632 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
| 633 | + |
|
| 634 | + $this->registerService(AppManager::class, function (Server $c) { |
|
| 635 | + return new \OC\App\AppManager( |
|
| 636 | + $c->getUserSession(), |
|
| 637 | + $c->getAppConfig(), |
|
| 638 | + $c->getGroupManager(), |
|
| 639 | + $c->getMemCacheFactory(), |
|
| 640 | + $c->getEventDispatcher() |
|
| 641 | + ); |
|
| 642 | + }); |
|
| 643 | + $this->registerAlias('AppManager', AppManager::class); |
|
| 644 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
| 645 | + |
|
| 646 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 647 | + return new DateTimeZone( |
|
| 648 | + $c->getConfig(), |
|
| 649 | + $c->getSession() |
|
| 650 | + ); |
|
| 651 | + }); |
|
| 652 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
| 653 | + |
|
| 654 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 655 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
| 656 | + |
|
| 657 | + return new DateTimeFormatter( |
|
| 658 | + $c->getDateTimeZone()->getTimeZone(), |
|
| 659 | + $c->getL10N('lib', $language) |
|
| 660 | + ); |
|
| 661 | + }); |
|
| 662 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
| 663 | + |
|
| 664 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 665 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
| 666 | + $listener = new UserMountCacheListener($mountCache); |
|
| 667 | + $listener->listen($c->getUserManager()); |
|
| 668 | + return $mountCache; |
|
| 669 | + }); |
|
| 670 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
| 671 | + |
|
| 672 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 673 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
| 674 | + $mountCache = $c->query('UserMountCache'); |
|
| 675 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 676 | + |
|
| 677 | + // builtin providers |
|
| 678 | + |
|
| 679 | + $config = $c->getConfig(); |
|
| 680 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
| 681 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
| 682 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
| 683 | + |
|
| 684 | + return $manager; |
|
| 685 | + }); |
|
| 686 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
| 687 | + |
|
| 688 | + $this->registerService('IniWrapper', function ($c) { |
|
| 689 | + return new IniGetWrapper(); |
|
| 690 | + }); |
|
| 691 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 692 | + $jobList = $c->getJobList(); |
|
| 693 | + return new AsyncBus($jobList); |
|
| 694 | + }); |
|
| 695 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 696 | + return new TrustedDomainHelper($this->getConfig()); |
|
| 697 | + }); |
|
| 698 | + $this->registerService('Throttler', function(Server $c) { |
|
| 699 | + return new Throttler( |
|
| 700 | + $c->getDatabaseConnection(), |
|
| 701 | + new TimeFactory(), |
|
| 702 | + $c->getLogger(), |
|
| 703 | + $c->getConfig() |
|
| 704 | + ); |
|
| 705 | + }); |
|
| 706 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 707 | + // IConfig and IAppManager requires a working database. This code |
|
| 708 | + // might however be called when ownCloud is not yet setup. |
|
| 709 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 710 | + $config = $c->getConfig(); |
|
| 711 | + $appManager = $c->getAppManager(); |
|
| 712 | + } else { |
|
| 713 | + $config = null; |
|
| 714 | + $appManager = null; |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + return new Checker( |
|
| 718 | + new EnvironmentHelper(), |
|
| 719 | + new FileAccessHelper(), |
|
| 720 | + new AppLocator(), |
|
| 721 | + $config, |
|
| 722 | + $c->getMemCacheFactory(), |
|
| 723 | + $appManager, |
|
| 724 | + $c->getTempManager() |
|
| 725 | + ); |
|
| 726 | + }); |
|
| 727 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 728 | + if (isset($this['urlParams'])) { |
|
| 729 | + $urlParams = $this['urlParams']; |
|
| 730 | + } else { |
|
| 731 | + $urlParams = []; |
|
| 732 | + } |
|
| 733 | + |
|
| 734 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
| 735 | + && in_array('fakeinput', stream_get_wrappers()) |
|
| 736 | + ) { |
|
| 737 | + $stream = 'fakeinput://data'; |
|
| 738 | + } else { |
|
| 739 | + $stream = 'php://input'; |
|
| 740 | + } |
|
| 741 | + |
|
| 742 | + return new Request( |
|
| 743 | + [ |
|
| 744 | + 'get' => $_GET, |
|
| 745 | + 'post' => $_POST, |
|
| 746 | + 'files' => $_FILES, |
|
| 747 | + 'server' => $_SERVER, |
|
| 748 | + 'env' => $_ENV, |
|
| 749 | + 'cookies' => $_COOKIE, |
|
| 750 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 751 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 752 | + : null, |
|
| 753 | + 'urlParams' => $urlParams, |
|
| 754 | + ], |
|
| 755 | + $this->getSecureRandom(), |
|
| 756 | + $this->getConfig(), |
|
| 757 | + $this->getCsrfTokenManager(), |
|
| 758 | + $stream |
|
| 759 | + ); |
|
| 760 | + }); |
|
| 761 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
| 762 | + |
|
| 763 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 764 | + return new Mailer( |
|
| 765 | + $c->getConfig(), |
|
| 766 | + $c->getLogger(), |
|
| 767 | + $c->query(Defaults::class), |
|
| 768 | + $c->getURLGenerator(), |
|
| 769 | + $c->getL10N('lib') |
|
| 770 | + ); |
|
| 771 | + }); |
|
| 772 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
| 773 | + |
|
| 774 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
| 775 | + $config = $c->getConfig(); |
|
| 776 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
| 777 | + if(is_null($factoryClass)) { |
|
| 778 | + throw new \Exception('ldapProviderFactory not set'); |
|
| 779 | + } |
|
| 780 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
| 781 | + $factory = new $factoryClass($this); |
|
| 782 | + return $factory->getLDAPProvider(); |
|
| 783 | + }); |
|
| 784 | + $this->registerService('LockingProvider', function (Server $c) { |
|
| 785 | + $ini = $c->getIniWrapper(); |
|
| 786 | + $config = $c->getConfig(); |
|
| 787 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
| 788 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
| 789 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
| 790 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
| 791 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
| 792 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
| 793 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
| 794 | + } |
|
| 795 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
| 796 | + } |
|
| 797 | + return new NoopLockingProvider(); |
|
| 798 | + }); |
|
| 799 | + |
|
| 800 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 801 | + return new \OC\Files\Mount\Manager(); |
|
| 802 | + }); |
|
| 803 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
| 804 | + |
|
| 805 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 806 | + return new \OC\Files\Type\Detection( |
|
| 807 | + $c->getURLGenerator(), |
|
| 808 | + \OC::$configDir, |
|
| 809 | + \OC::$SERVERROOT . '/resources/config/' |
|
| 810 | + ); |
|
| 811 | + }); |
|
| 812 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
| 813 | + |
|
| 814 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 815 | + return new \OC\Files\Type\Loader( |
|
| 816 | + $c->getDatabaseConnection() |
|
| 817 | + ); |
|
| 818 | + }); |
|
| 819 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
| 820 | + |
|
| 821 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 822 | + return new Manager( |
|
| 823 | + $c->query(IValidator::class) |
|
| 824 | + ); |
|
| 825 | + }); |
|
| 826 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
| 827 | + |
|
| 828 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 829 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
| 830 | + $manager->registerCapability(function () use ($c) { |
|
| 831 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
| 832 | + }); |
|
| 833 | + return $manager; |
|
| 834 | + }); |
|
| 835 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
| 836 | + |
|
| 837 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
| 838 | + $config = $c->getConfig(); |
|
| 839 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
| 840 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
| 841 | + $factory = new $factoryClass($this); |
|
| 842 | + return $factory->getManager(); |
|
| 843 | + }); |
|
| 844 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
| 845 | + |
|
| 846 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
| 847 | + /* |
|
| 848 | 848 | * Dark magic for autoloader. |
| 849 | 849 | * If we do a class_exists it will try to load the class which will |
| 850 | 850 | * make composer cache the result. Resulting in errors when enabling |
| 851 | 851 | * the theming app. |
| 852 | 852 | */ |
| 853 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 854 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 855 | - $classExists = true; |
|
| 856 | - } else { |
|
| 857 | - $classExists = false; |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
| 861 | - return new ThemingDefaults( |
|
| 862 | - $c->getConfig(), |
|
| 863 | - $c->getL10N('theming'), |
|
| 864 | - $c->getURLGenerator(), |
|
| 865 | - new \OC_Defaults(), |
|
| 866 | - $c->getAppDataDir('theming'), |
|
| 867 | - $c->getMemCacheFactory(), |
|
| 868 | - new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
| 869 | - ); |
|
| 870 | - } |
|
| 871 | - return new \OC_Defaults(); |
|
| 872 | - }); |
|
| 873 | - $this->registerService(SCSSCacher::class, function(Server $c) { |
|
| 874 | - /** @var Factory $cacheFactory */ |
|
| 875 | - $cacheFactory = $c->query(Factory::class); |
|
| 876 | - return new SCSSCacher( |
|
| 877 | - $c->getLogger(), |
|
| 878 | - $c->query(\OC\Files\AppData\Factory::class), |
|
| 879 | - $c->getURLGenerator(), |
|
| 880 | - $c->getConfig(), |
|
| 881 | - $c->getThemingDefaults(), |
|
| 882 | - \OC::$SERVERROOT, |
|
| 883 | - $cacheFactory->createLocal('SCSS') |
|
| 884 | - ); |
|
| 885 | - }); |
|
| 886 | - $this->registerService(EventDispatcher::class, function () { |
|
| 887 | - return new EventDispatcher(); |
|
| 888 | - }); |
|
| 889 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
| 890 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
| 891 | - |
|
| 892 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 893 | - // FIXME: Instantiiated here due to cyclic dependency |
|
| 894 | - $request = new Request( |
|
| 895 | - [ |
|
| 896 | - 'get' => $_GET, |
|
| 897 | - 'post' => $_POST, |
|
| 898 | - 'files' => $_FILES, |
|
| 899 | - 'server' => $_SERVER, |
|
| 900 | - 'env' => $_ENV, |
|
| 901 | - 'cookies' => $_COOKIE, |
|
| 902 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 903 | - ? $_SERVER['REQUEST_METHOD'] |
|
| 904 | - : null, |
|
| 905 | - ], |
|
| 906 | - $c->getSecureRandom(), |
|
| 907 | - $c->getConfig() |
|
| 908 | - ); |
|
| 909 | - |
|
| 910 | - return new CryptoWrapper( |
|
| 911 | - $c->getConfig(), |
|
| 912 | - $c->getCrypto(), |
|
| 913 | - $c->getSecureRandom(), |
|
| 914 | - $request |
|
| 915 | - ); |
|
| 916 | - }); |
|
| 917 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 918 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 919 | - |
|
| 920 | - return new CsrfTokenManager( |
|
| 921 | - $tokenGenerator, |
|
| 922 | - $c->query(SessionStorage::class) |
|
| 923 | - ); |
|
| 924 | - }); |
|
| 925 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 926 | - return new SessionStorage($c->getSession()); |
|
| 927 | - }); |
|
| 928 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 929 | - return new ContentSecurityPolicyManager(); |
|
| 930 | - }); |
|
| 931 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
| 932 | - |
|
| 933 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
| 934 | - return new ContentSecurityPolicyNonceManager( |
|
| 935 | - $c->getCsrfTokenManager(), |
|
| 936 | - $c->getRequest() |
|
| 937 | - ); |
|
| 938 | - }); |
|
| 939 | - |
|
| 940 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
| 941 | - $config = $c->getConfig(); |
|
| 942 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
| 943 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 944 | - $factory = new $factoryClass($this); |
|
| 945 | - |
|
| 946 | - $manager = new \OC\Share20\Manager( |
|
| 947 | - $c->getLogger(), |
|
| 948 | - $c->getConfig(), |
|
| 949 | - $c->getSecureRandom(), |
|
| 950 | - $c->getHasher(), |
|
| 951 | - $c->getMountManager(), |
|
| 952 | - $c->getGroupManager(), |
|
| 953 | - $c->getL10N('core'), |
|
| 954 | - $factory, |
|
| 955 | - $c->getUserManager(), |
|
| 956 | - $c->getLazyRootFolder(), |
|
| 957 | - $c->getEventDispatcher() |
|
| 958 | - ); |
|
| 959 | - |
|
| 960 | - return $manager; |
|
| 961 | - }); |
|
| 962 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 963 | - |
|
| 964 | - $this->registerService('SettingsManager', function(Server $c) { |
|
| 965 | - $manager = new \OC\Settings\Manager( |
|
| 966 | - $c->getLogger(), |
|
| 967 | - $c->getDatabaseConnection(), |
|
| 968 | - $c->getL10N('lib'), |
|
| 969 | - $c->getConfig(), |
|
| 970 | - $c->getEncryptionManager(), |
|
| 971 | - $c->getUserManager(), |
|
| 972 | - $c->getLockingProvider(), |
|
| 973 | - $c->getRequest(), |
|
| 974 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
| 975 | - $c->getURLGenerator() |
|
| 976 | - ); |
|
| 977 | - return $manager; |
|
| 978 | - }); |
|
| 979 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 980 | - return new \OC\Files\AppData\Factory( |
|
| 981 | - $c->getRootFolder(), |
|
| 982 | - $c->getSystemConfig() |
|
| 983 | - ); |
|
| 984 | - }); |
|
| 985 | - |
|
| 986 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 987 | - return new LockdownManager(function() use ($c) { |
|
| 988 | - return $c->getSession(); |
|
| 989 | - }); |
|
| 990 | - }); |
|
| 991 | - |
|
| 992 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 993 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 994 | - }); |
|
| 995 | - |
|
| 996 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 997 | - return new CloudIdManager(); |
|
| 998 | - }); |
|
| 999 | - |
|
| 1000 | - /* To trick DI since we don't extend the DIContainer here */ |
|
| 1001 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
| 1002 | - return new CleanPreviewsBackgroundJob( |
|
| 1003 | - $c->getRootFolder(), |
|
| 1004 | - $c->getLogger(), |
|
| 1005 | - $c->getJobList(), |
|
| 1006 | - new TimeFactory() |
|
| 1007 | - ); |
|
| 1008 | - }); |
|
| 1009 | - |
|
| 1010 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1011 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1012 | - |
|
| 1013 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1014 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1015 | - |
|
| 1016 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1017 | - return new Defaults( |
|
| 1018 | - $c->getThemingDefaults() |
|
| 1019 | - ); |
|
| 1020 | - }); |
|
| 1021 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
| 1022 | - |
|
| 1023 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
| 1024 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1025 | - }); |
|
| 1026 | - |
|
| 1027 | - $this->registerService(IShareHelper::class, function(Server $c) { |
|
| 1028 | - return new ShareHelper( |
|
| 1029 | - $c->query(\OCP\Share\IManager::class) |
|
| 1030 | - ); |
|
| 1031 | - }); |
|
| 1032 | - } |
|
| 1033 | - |
|
| 1034 | - /** |
|
| 1035 | - * @return \OCP\Contacts\IManager |
|
| 1036 | - */ |
|
| 1037 | - public function getContactsManager() { |
|
| 1038 | - return $this->query('ContactsManager'); |
|
| 1039 | - } |
|
| 1040 | - |
|
| 1041 | - /** |
|
| 1042 | - * @return \OC\Encryption\Manager |
|
| 1043 | - */ |
|
| 1044 | - public function getEncryptionManager() { |
|
| 1045 | - return $this->query('EncryptionManager'); |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - /** |
|
| 1049 | - * @return \OC\Encryption\File |
|
| 1050 | - */ |
|
| 1051 | - public function getEncryptionFilesHelper() { |
|
| 1052 | - return $this->query('EncryptionFileHelper'); |
|
| 1053 | - } |
|
| 1054 | - |
|
| 1055 | - /** |
|
| 1056 | - * @return \OCP\Encryption\Keys\IStorage |
|
| 1057 | - */ |
|
| 1058 | - public function getEncryptionKeyStorage() { |
|
| 1059 | - return $this->query('EncryptionKeyStorage'); |
|
| 1060 | - } |
|
| 1061 | - |
|
| 1062 | - /** |
|
| 1063 | - * The current request object holding all information about the request |
|
| 1064 | - * currently being processed is returned from this method. |
|
| 1065 | - * In case the current execution was not initiated by a web request null is returned |
|
| 1066 | - * |
|
| 1067 | - * @return \OCP\IRequest |
|
| 1068 | - */ |
|
| 1069 | - public function getRequest() { |
|
| 1070 | - return $this->query('Request'); |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - /** |
|
| 1074 | - * Returns the preview manager which can create preview images for a given file |
|
| 1075 | - * |
|
| 1076 | - * @return \OCP\IPreview |
|
| 1077 | - */ |
|
| 1078 | - public function getPreviewManager() { |
|
| 1079 | - return $this->query('PreviewManager'); |
|
| 1080 | - } |
|
| 1081 | - |
|
| 1082 | - /** |
|
| 1083 | - * Returns the tag manager which can get and set tags for different object types |
|
| 1084 | - * |
|
| 1085 | - * @see \OCP\ITagManager::load() |
|
| 1086 | - * @return \OCP\ITagManager |
|
| 1087 | - */ |
|
| 1088 | - public function getTagManager() { |
|
| 1089 | - return $this->query('TagManager'); |
|
| 1090 | - } |
|
| 1091 | - |
|
| 1092 | - /** |
|
| 1093 | - * Returns the system-tag manager |
|
| 1094 | - * |
|
| 1095 | - * @return \OCP\SystemTag\ISystemTagManager |
|
| 1096 | - * |
|
| 1097 | - * @since 9.0.0 |
|
| 1098 | - */ |
|
| 1099 | - public function getSystemTagManager() { |
|
| 1100 | - return $this->query('SystemTagManager'); |
|
| 1101 | - } |
|
| 1102 | - |
|
| 1103 | - /** |
|
| 1104 | - * Returns the system-tag object mapper |
|
| 1105 | - * |
|
| 1106 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 1107 | - * |
|
| 1108 | - * @since 9.0.0 |
|
| 1109 | - */ |
|
| 1110 | - public function getSystemTagObjectMapper() { |
|
| 1111 | - return $this->query('SystemTagObjectMapper'); |
|
| 1112 | - } |
|
| 1113 | - |
|
| 1114 | - /** |
|
| 1115 | - * Returns the avatar manager, used for avatar functionality |
|
| 1116 | - * |
|
| 1117 | - * @return \OCP\IAvatarManager |
|
| 1118 | - */ |
|
| 1119 | - public function getAvatarManager() { |
|
| 1120 | - return $this->query('AvatarManager'); |
|
| 1121 | - } |
|
| 1122 | - |
|
| 1123 | - /** |
|
| 1124 | - * Returns the root folder of ownCloud's data directory |
|
| 1125 | - * |
|
| 1126 | - * @return \OCP\Files\IRootFolder |
|
| 1127 | - */ |
|
| 1128 | - public function getRootFolder() { |
|
| 1129 | - return $this->query('LazyRootFolder'); |
|
| 1130 | - } |
|
| 1131 | - |
|
| 1132 | - /** |
|
| 1133 | - * Returns the root folder of ownCloud's data directory |
|
| 1134 | - * This is the lazy variant so this gets only initialized once it |
|
| 1135 | - * is actually used. |
|
| 1136 | - * |
|
| 1137 | - * @return \OCP\Files\IRootFolder |
|
| 1138 | - */ |
|
| 1139 | - public function getLazyRootFolder() { |
|
| 1140 | - return $this->query('LazyRootFolder'); |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - /** |
|
| 1144 | - * Returns a view to ownCloud's files folder |
|
| 1145 | - * |
|
| 1146 | - * @param string $userId user ID |
|
| 1147 | - * @return \OCP\Files\Folder|null |
|
| 1148 | - */ |
|
| 1149 | - public function getUserFolder($userId = null) { |
|
| 1150 | - if ($userId === null) { |
|
| 1151 | - $user = $this->getUserSession()->getUser(); |
|
| 1152 | - if (!$user) { |
|
| 1153 | - return null; |
|
| 1154 | - } |
|
| 1155 | - $userId = $user->getUID(); |
|
| 1156 | - } |
|
| 1157 | - $root = $this->getRootFolder(); |
|
| 1158 | - return $root->getUserFolder($userId); |
|
| 1159 | - } |
|
| 1160 | - |
|
| 1161 | - /** |
|
| 1162 | - * Returns an app-specific view in ownClouds data directory |
|
| 1163 | - * |
|
| 1164 | - * @return \OCP\Files\Folder |
|
| 1165 | - * @deprecated since 9.2.0 use IAppData |
|
| 1166 | - */ |
|
| 1167 | - public function getAppFolder() { |
|
| 1168 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1169 | - $root = $this->getRootFolder(); |
|
| 1170 | - if (!$root->nodeExists($dir)) { |
|
| 1171 | - $folder = $root->newFolder($dir); |
|
| 1172 | - } else { |
|
| 1173 | - $folder = $root->get($dir); |
|
| 1174 | - } |
|
| 1175 | - return $folder; |
|
| 1176 | - } |
|
| 1177 | - |
|
| 1178 | - /** |
|
| 1179 | - * @return \OC\User\Manager |
|
| 1180 | - */ |
|
| 1181 | - public function getUserManager() { |
|
| 1182 | - return $this->query('UserManager'); |
|
| 1183 | - } |
|
| 1184 | - |
|
| 1185 | - /** |
|
| 1186 | - * @return \OC\Group\Manager |
|
| 1187 | - */ |
|
| 1188 | - public function getGroupManager() { |
|
| 1189 | - return $this->query('GroupManager'); |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - /** |
|
| 1193 | - * @return \OC\User\Session |
|
| 1194 | - */ |
|
| 1195 | - public function getUserSession() { |
|
| 1196 | - return $this->query('UserSession'); |
|
| 1197 | - } |
|
| 1198 | - |
|
| 1199 | - /** |
|
| 1200 | - * @return \OCP\ISession |
|
| 1201 | - */ |
|
| 1202 | - public function getSession() { |
|
| 1203 | - return $this->query('UserSession')->getSession(); |
|
| 1204 | - } |
|
| 1205 | - |
|
| 1206 | - /** |
|
| 1207 | - * @param \OCP\ISession $session |
|
| 1208 | - */ |
|
| 1209 | - public function setSession(\OCP\ISession $session) { |
|
| 1210 | - $this->query(SessionStorage::class)->setSession($session); |
|
| 1211 | - $this->query('UserSession')->setSession($session); |
|
| 1212 | - $this->query(Store::class)->setSession($session); |
|
| 1213 | - } |
|
| 1214 | - |
|
| 1215 | - /** |
|
| 1216 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1217 | - */ |
|
| 1218 | - public function getTwoFactorAuthManager() { |
|
| 1219 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
| 1220 | - } |
|
| 1221 | - |
|
| 1222 | - /** |
|
| 1223 | - * @return \OC\NavigationManager |
|
| 1224 | - */ |
|
| 1225 | - public function getNavigationManager() { |
|
| 1226 | - return $this->query('NavigationManager'); |
|
| 1227 | - } |
|
| 1228 | - |
|
| 1229 | - /** |
|
| 1230 | - * @return \OCP\IConfig |
|
| 1231 | - */ |
|
| 1232 | - public function getConfig() { |
|
| 1233 | - return $this->query('AllConfig'); |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - /** |
|
| 1237 | - * @internal For internal use only |
|
| 1238 | - * @return \OC\SystemConfig |
|
| 1239 | - */ |
|
| 1240 | - public function getSystemConfig() { |
|
| 1241 | - return $this->query('SystemConfig'); |
|
| 1242 | - } |
|
| 1243 | - |
|
| 1244 | - /** |
|
| 1245 | - * Returns the app config manager |
|
| 1246 | - * |
|
| 1247 | - * @return \OCP\IAppConfig |
|
| 1248 | - */ |
|
| 1249 | - public function getAppConfig() { |
|
| 1250 | - return $this->query('AppConfig'); |
|
| 1251 | - } |
|
| 1252 | - |
|
| 1253 | - /** |
|
| 1254 | - * @return \OCP\L10N\IFactory |
|
| 1255 | - */ |
|
| 1256 | - public function getL10NFactory() { |
|
| 1257 | - return $this->query('L10NFactory'); |
|
| 1258 | - } |
|
| 1259 | - |
|
| 1260 | - /** |
|
| 1261 | - * get an L10N instance |
|
| 1262 | - * |
|
| 1263 | - * @param string $app appid |
|
| 1264 | - * @param string $lang |
|
| 1265 | - * @return IL10N |
|
| 1266 | - */ |
|
| 1267 | - public function getL10N($app, $lang = null) { |
|
| 1268 | - return $this->getL10NFactory()->get($app, $lang); |
|
| 1269 | - } |
|
| 1270 | - |
|
| 1271 | - /** |
|
| 1272 | - * @return \OCP\IURLGenerator |
|
| 1273 | - */ |
|
| 1274 | - public function getURLGenerator() { |
|
| 1275 | - return $this->query('URLGenerator'); |
|
| 1276 | - } |
|
| 1277 | - |
|
| 1278 | - /** |
|
| 1279 | - * @return \OCP\IHelper |
|
| 1280 | - */ |
|
| 1281 | - public function getHelper() { |
|
| 1282 | - return $this->query('AppHelper'); |
|
| 1283 | - } |
|
| 1284 | - |
|
| 1285 | - /** |
|
| 1286 | - * @return AppFetcher |
|
| 1287 | - */ |
|
| 1288 | - public function getAppFetcher() { |
|
| 1289 | - return $this->query('AppFetcher'); |
|
| 1290 | - } |
|
| 1291 | - |
|
| 1292 | - /** |
|
| 1293 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1294 | - * getMemCacheFactory() instead. |
|
| 1295 | - * |
|
| 1296 | - * @return \OCP\ICache |
|
| 1297 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1298 | - */ |
|
| 1299 | - public function getCache() { |
|
| 1300 | - return $this->query('UserCache'); |
|
| 1301 | - } |
|
| 1302 | - |
|
| 1303 | - /** |
|
| 1304 | - * Returns an \OCP\CacheFactory instance |
|
| 1305 | - * |
|
| 1306 | - * @return \OCP\ICacheFactory |
|
| 1307 | - */ |
|
| 1308 | - public function getMemCacheFactory() { |
|
| 1309 | - return $this->query('MemCacheFactory'); |
|
| 1310 | - } |
|
| 1311 | - |
|
| 1312 | - /** |
|
| 1313 | - * Returns an \OC\RedisFactory instance |
|
| 1314 | - * |
|
| 1315 | - * @return \OC\RedisFactory |
|
| 1316 | - */ |
|
| 1317 | - public function getGetRedisFactory() { |
|
| 1318 | - return $this->query('RedisFactory'); |
|
| 1319 | - } |
|
| 1320 | - |
|
| 1321 | - |
|
| 1322 | - /** |
|
| 1323 | - * Returns the current session |
|
| 1324 | - * |
|
| 1325 | - * @return \OCP\IDBConnection |
|
| 1326 | - */ |
|
| 1327 | - public function getDatabaseConnection() { |
|
| 1328 | - return $this->query('DatabaseConnection'); |
|
| 1329 | - } |
|
| 1330 | - |
|
| 1331 | - /** |
|
| 1332 | - * Returns the activity manager |
|
| 1333 | - * |
|
| 1334 | - * @return \OCP\Activity\IManager |
|
| 1335 | - */ |
|
| 1336 | - public function getActivityManager() { |
|
| 1337 | - return $this->query('ActivityManager'); |
|
| 1338 | - } |
|
| 1339 | - |
|
| 1340 | - /** |
|
| 1341 | - * Returns an job list for controlling background jobs |
|
| 1342 | - * |
|
| 1343 | - * @return \OCP\BackgroundJob\IJobList |
|
| 1344 | - */ |
|
| 1345 | - public function getJobList() { |
|
| 1346 | - return $this->query('JobList'); |
|
| 1347 | - } |
|
| 1348 | - |
|
| 1349 | - /** |
|
| 1350 | - * Returns a logger instance |
|
| 1351 | - * |
|
| 1352 | - * @return \OCP\ILogger |
|
| 1353 | - */ |
|
| 1354 | - public function getLogger() { |
|
| 1355 | - return $this->query('Logger'); |
|
| 1356 | - } |
|
| 1357 | - |
|
| 1358 | - /** |
|
| 1359 | - * Returns a router for generating and matching urls |
|
| 1360 | - * |
|
| 1361 | - * @return \OCP\Route\IRouter |
|
| 1362 | - */ |
|
| 1363 | - public function getRouter() { |
|
| 1364 | - return $this->query('Router'); |
|
| 1365 | - } |
|
| 1366 | - |
|
| 1367 | - /** |
|
| 1368 | - * Returns a search instance |
|
| 1369 | - * |
|
| 1370 | - * @return \OCP\ISearch |
|
| 1371 | - */ |
|
| 1372 | - public function getSearch() { |
|
| 1373 | - return $this->query('Search'); |
|
| 1374 | - } |
|
| 1375 | - |
|
| 1376 | - /** |
|
| 1377 | - * Returns a SecureRandom instance |
|
| 1378 | - * |
|
| 1379 | - * @return \OCP\Security\ISecureRandom |
|
| 1380 | - */ |
|
| 1381 | - public function getSecureRandom() { |
|
| 1382 | - return $this->query('SecureRandom'); |
|
| 1383 | - } |
|
| 1384 | - |
|
| 1385 | - /** |
|
| 1386 | - * Returns a Crypto instance |
|
| 1387 | - * |
|
| 1388 | - * @return \OCP\Security\ICrypto |
|
| 1389 | - */ |
|
| 1390 | - public function getCrypto() { |
|
| 1391 | - return $this->query('Crypto'); |
|
| 1392 | - } |
|
| 1393 | - |
|
| 1394 | - /** |
|
| 1395 | - * Returns a Hasher instance |
|
| 1396 | - * |
|
| 1397 | - * @return \OCP\Security\IHasher |
|
| 1398 | - */ |
|
| 1399 | - public function getHasher() { |
|
| 1400 | - return $this->query('Hasher'); |
|
| 1401 | - } |
|
| 1402 | - |
|
| 1403 | - /** |
|
| 1404 | - * Returns a CredentialsManager instance |
|
| 1405 | - * |
|
| 1406 | - * @return \OCP\Security\ICredentialsManager |
|
| 1407 | - */ |
|
| 1408 | - public function getCredentialsManager() { |
|
| 1409 | - return $this->query('CredentialsManager'); |
|
| 1410 | - } |
|
| 1411 | - |
|
| 1412 | - /** |
|
| 1413 | - * Returns an instance of the HTTP helper class |
|
| 1414 | - * |
|
| 1415 | - * @deprecated Use getHTTPClientService() |
|
| 1416 | - * @return \OC\HTTPHelper |
|
| 1417 | - */ |
|
| 1418 | - public function getHTTPHelper() { |
|
| 1419 | - return $this->query('HTTPHelper'); |
|
| 1420 | - } |
|
| 1421 | - |
|
| 1422 | - /** |
|
| 1423 | - * Get the certificate manager for the user |
|
| 1424 | - * |
|
| 1425 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1426 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1427 | - */ |
|
| 1428 | - public function getCertificateManager($userId = '') { |
|
| 1429 | - if ($userId === '') { |
|
| 1430 | - $userSession = $this->getUserSession(); |
|
| 1431 | - $user = $userSession->getUser(); |
|
| 1432 | - if (is_null($user)) { |
|
| 1433 | - return null; |
|
| 1434 | - } |
|
| 1435 | - $userId = $user->getUID(); |
|
| 1436 | - } |
|
| 1437 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
| 1438 | - } |
|
| 1439 | - |
|
| 1440 | - /** |
|
| 1441 | - * Returns an instance of the HTTP client service |
|
| 1442 | - * |
|
| 1443 | - * @return \OCP\Http\Client\IClientService |
|
| 1444 | - */ |
|
| 1445 | - public function getHTTPClientService() { |
|
| 1446 | - return $this->query('HttpClientService'); |
|
| 1447 | - } |
|
| 1448 | - |
|
| 1449 | - /** |
|
| 1450 | - * Create a new event source |
|
| 1451 | - * |
|
| 1452 | - * @return \OCP\IEventSource |
|
| 1453 | - */ |
|
| 1454 | - public function createEventSource() { |
|
| 1455 | - return new \OC_EventSource(); |
|
| 1456 | - } |
|
| 1457 | - |
|
| 1458 | - /** |
|
| 1459 | - * Get the active event logger |
|
| 1460 | - * |
|
| 1461 | - * The returned logger only logs data when debug mode is enabled |
|
| 1462 | - * |
|
| 1463 | - * @return \OCP\Diagnostics\IEventLogger |
|
| 1464 | - */ |
|
| 1465 | - public function getEventLogger() { |
|
| 1466 | - return $this->query('EventLogger'); |
|
| 1467 | - } |
|
| 1468 | - |
|
| 1469 | - /** |
|
| 1470 | - * Get the active query logger |
|
| 1471 | - * |
|
| 1472 | - * The returned logger only logs data when debug mode is enabled |
|
| 1473 | - * |
|
| 1474 | - * @return \OCP\Diagnostics\IQueryLogger |
|
| 1475 | - */ |
|
| 1476 | - public function getQueryLogger() { |
|
| 1477 | - return $this->query('QueryLogger'); |
|
| 1478 | - } |
|
| 1479 | - |
|
| 1480 | - /** |
|
| 1481 | - * Get the manager for temporary files and folders |
|
| 1482 | - * |
|
| 1483 | - * @return \OCP\ITempManager |
|
| 1484 | - */ |
|
| 1485 | - public function getTempManager() { |
|
| 1486 | - return $this->query('TempManager'); |
|
| 1487 | - } |
|
| 1488 | - |
|
| 1489 | - /** |
|
| 1490 | - * Get the app manager |
|
| 1491 | - * |
|
| 1492 | - * @return \OCP\App\IAppManager |
|
| 1493 | - */ |
|
| 1494 | - public function getAppManager() { |
|
| 1495 | - return $this->query('AppManager'); |
|
| 1496 | - } |
|
| 1497 | - |
|
| 1498 | - /** |
|
| 1499 | - * Creates a new mailer |
|
| 1500 | - * |
|
| 1501 | - * @return \OCP\Mail\IMailer |
|
| 1502 | - */ |
|
| 1503 | - public function getMailer() { |
|
| 1504 | - return $this->query('Mailer'); |
|
| 1505 | - } |
|
| 1506 | - |
|
| 1507 | - /** |
|
| 1508 | - * Get the webroot |
|
| 1509 | - * |
|
| 1510 | - * @return string |
|
| 1511 | - */ |
|
| 1512 | - public function getWebRoot() { |
|
| 1513 | - return $this->webRoot; |
|
| 1514 | - } |
|
| 1515 | - |
|
| 1516 | - /** |
|
| 1517 | - * @return \OC\OCSClient |
|
| 1518 | - */ |
|
| 1519 | - public function getOcsClient() { |
|
| 1520 | - return $this->query('OcsClient'); |
|
| 1521 | - } |
|
| 1522 | - |
|
| 1523 | - /** |
|
| 1524 | - * @return \OCP\IDateTimeZone |
|
| 1525 | - */ |
|
| 1526 | - public function getDateTimeZone() { |
|
| 1527 | - return $this->query('DateTimeZone'); |
|
| 1528 | - } |
|
| 1529 | - |
|
| 1530 | - /** |
|
| 1531 | - * @return \OCP\IDateTimeFormatter |
|
| 1532 | - */ |
|
| 1533 | - public function getDateTimeFormatter() { |
|
| 1534 | - return $this->query('DateTimeFormatter'); |
|
| 1535 | - } |
|
| 1536 | - |
|
| 1537 | - /** |
|
| 1538 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
| 1539 | - */ |
|
| 1540 | - public function getMountProviderCollection() { |
|
| 1541 | - return $this->query('MountConfigManager'); |
|
| 1542 | - } |
|
| 1543 | - |
|
| 1544 | - /** |
|
| 1545 | - * Get the IniWrapper |
|
| 1546 | - * |
|
| 1547 | - * @return IniGetWrapper |
|
| 1548 | - */ |
|
| 1549 | - public function getIniWrapper() { |
|
| 1550 | - return $this->query('IniWrapper'); |
|
| 1551 | - } |
|
| 1552 | - |
|
| 1553 | - /** |
|
| 1554 | - * @return \OCP\Command\IBus |
|
| 1555 | - */ |
|
| 1556 | - public function getCommandBus() { |
|
| 1557 | - return $this->query('AsyncCommandBus'); |
|
| 1558 | - } |
|
| 1559 | - |
|
| 1560 | - /** |
|
| 1561 | - * Get the trusted domain helper |
|
| 1562 | - * |
|
| 1563 | - * @return TrustedDomainHelper |
|
| 1564 | - */ |
|
| 1565 | - public function getTrustedDomainHelper() { |
|
| 1566 | - return $this->query('TrustedDomainHelper'); |
|
| 1567 | - } |
|
| 1568 | - |
|
| 1569 | - /** |
|
| 1570 | - * Get the locking provider |
|
| 1571 | - * |
|
| 1572 | - * @return \OCP\Lock\ILockingProvider |
|
| 1573 | - * @since 8.1.0 |
|
| 1574 | - */ |
|
| 1575 | - public function getLockingProvider() { |
|
| 1576 | - return $this->query('LockingProvider'); |
|
| 1577 | - } |
|
| 1578 | - |
|
| 1579 | - /** |
|
| 1580 | - * @return \OCP\Files\Mount\IMountManager |
|
| 1581 | - **/ |
|
| 1582 | - function getMountManager() { |
|
| 1583 | - return $this->query('MountManager'); |
|
| 1584 | - } |
|
| 1585 | - |
|
| 1586 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
| 1587 | - function getUserMountCache() { |
|
| 1588 | - return $this->query('UserMountCache'); |
|
| 1589 | - } |
|
| 1590 | - |
|
| 1591 | - /** |
|
| 1592 | - * Get the MimeTypeDetector |
|
| 1593 | - * |
|
| 1594 | - * @return \OCP\Files\IMimeTypeDetector |
|
| 1595 | - */ |
|
| 1596 | - public function getMimeTypeDetector() { |
|
| 1597 | - return $this->query('MimeTypeDetector'); |
|
| 1598 | - } |
|
| 1599 | - |
|
| 1600 | - /** |
|
| 1601 | - * Get the MimeTypeLoader |
|
| 1602 | - * |
|
| 1603 | - * @return \OCP\Files\IMimeTypeLoader |
|
| 1604 | - */ |
|
| 1605 | - public function getMimeTypeLoader() { |
|
| 1606 | - return $this->query('MimeTypeLoader'); |
|
| 1607 | - } |
|
| 1608 | - |
|
| 1609 | - /** |
|
| 1610 | - * Get the manager of all the capabilities |
|
| 1611 | - * |
|
| 1612 | - * @return \OC\CapabilitiesManager |
|
| 1613 | - */ |
|
| 1614 | - public function getCapabilitiesManager() { |
|
| 1615 | - return $this->query('CapabilitiesManager'); |
|
| 1616 | - } |
|
| 1617 | - |
|
| 1618 | - /** |
|
| 1619 | - * Get the EventDispatcher |
|
| 1620 | - * |
|
| 1621 | - * @return EventDispatcherInterface |
|
| 1622 | - * @since 8.2.0 |
|
| 1623 | - */ |
|
| 1624 | - public function getEventDispatcher() { |
|
| 1625 | - return $this->query('EventDispatcher'); |
|
| 1626 | - } |
|
| 1627 | - |
|
| 1628 | - /** |
|
| 1629 | - * Get the Notification Manager |
|
| 1630 | - * |
|
| 1631 | - * @return \OCP\Notification\IManager |
|
| 1632 | - * @since 8.2.0 |
|
| 1633 | - */ |
|
| 1634 | - public function getNotificationManager() { |
|
| 1635 | - return $this->query('NotificationManager'); |
|
| 1636 | - } |
|
| 1637 | - |
|
| 1638 | - /** |
|
| 1639 | - * @return \OCP\Comments\ICommentsManager |
|
| 1640 | - */ |
|
| 1641 | - public function getCommentsManager() { |
|
| 1642 | - return $this->query('CommentsManager'); |
|
| 1643 | - } |
|
| 1644 | - |
|
| 1645 | - /** |
|
| 1646 | - * @return \OCA\Theming\ThemingDefaults |
|
| 1647 | - */ |
|
| 1648 | - public function getThemingDefaults() { |
|
| 1649 | - return $this->query('ThemingDefaults'); |
|
| 1650 | - } |
|
| 1651 | - |
|
| 1652 | - /** |
|
| 1653 | - * @return \OC\IntegrityCheck\Checker |
|
| 1654 | - */ |
|
| 1655 | - public function getIntegrityCodeChecker() { |
|
| 1656 | - return $this->query('IntegrityCodeChecker'); |
|
| 1657 | - } |
|
| 1658 | - |
|
| 1659 | - /** |
|
| 1660 | - * @return \OC\Session\CryptoWrapper |
|
| 1661 | - */ |
|
| 1662 | - public function getSessionCryptoWrapper() { |
|
| 1663 | - return $this->query('CryptoWrapper'); |
|
| 1664 | - } |
|
| 1665 | - |
|
| 1666 | - /** |
|
| 1667 | - * @return CsrfTokenManager |
|
| 1668 | - */ |
|
| 1669 | - public function getCsrfTokenManager() { |
|
| 1670 | - return $this->query('CsrfTokenManager'); |
|
| 1671 | - } |
|
| 1672 | - |
|
| 1673 | - /** |
|
| 1674 | - * @return Throttler |
|
| 1675 | - */ |
|
| 1676 | - public function getBruteForceThrottler() { |
|
| 1677 | - return $this->query('Throttler'); |
|
| 1678 | - } |
|
| 1679 | - |
|
| 1680 | - /** |
|
| 1681 | - * @return IContentSecurityPolicyManager |
|
| 1682 | - */ |
|
| 1683 | - public function getContentSecurityPolicyManager() { |
|
| 1684 | - return $this->query('ContentSecurityPolicyManager'); |
|
| 1685 | - } |
|
| 1686 | - |
|
| 1687 | - /** |
|
| 1688 | - * @return ContentSecurityPolicyNonceManager |
|
| 1689 | - */ |
|
| 1690 | - public function getContentSecurityPolicyNonceManager() { |
|
| 1691 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - /** |
|
| 1695 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1696 | - * |
|
| 1697 | - * @return \OCA\Files_External\Service\BackendService |
|
| 1698 | - */ |
|
| 1699 | - public function getStoragesBackendService() { |
|
| 1700 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
| 1701 | - } |
|
| 1702 | - |
|
| 1703 | - /** |
|
| 1704 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1705 | - * |
|
| 1706 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 1707 | - */ |
|
| 1708 | - public function getGlobalStoragesService() { |
|
| 1709 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
| 1710 | - } |
|
| 1711 | - |
|
| 1712 | - /** |
|
| 1713 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1714 | - * |
|
| 1715 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 1716 | - */ |
|
| 1717 | - public function getUserGlobalStoragesService() { |
|
| 1718 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
| 1719 | - } |
|
| 1720 | - |
|
| 1721 | - /** |
|
| 1722 | - * Not a public API as of 8.2, wait for 9.0 |
|
| 1723 | - * |
|
| 1724 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
| 1725 | - */ |
|
| 1726 | - public function getUserStoragesService() { |
|
| 1727 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
| 1728 | - } |
|
| 1729 | - |
|
| 1730 | - /** |
|
| 1731 | - * @return \OCP\Share\IManager |
|
| 1732 | - */ |
|
| 1733 | - public function getShareManager() { |
|
| 1734 | - return $this->query('ShareManager'); |
|
| 1735 | - } |
|
| 1736 | - |
|
| 1737 | - /** |
|
| 1738 | - * Returns the LDAP Provider |
|
| 1739 | - * |
|
| 1740 | - * @return \OCP\LDAP\ILDAPProvider |
|
| 1741 | - */ |
|
| 1742 | - public function getLDAPProvider() { |
|
| 1743 | - return $this->query('LDAPProvider'); |
|
| 1744 | - } |
|
| 1745 | - |
|
| 1746 | - /** |
|
| 1747 | - * @return \OCP\Settings\IManager |
|
| 1748 | - */ |
|
| 1749 | - public function getSettingsManager() { |
|
| 1750 | - return $this->query('SettingsManager'); |
|
| 1751 | - } |
|
| 1752 | - |
|
| 1753 | - /** |
|
| 1754 | - * @return \OCP\Files\IAppData |
|
| 1755 | - */ |
|
| 1756 | - public function getAppDataDir($app) { |
|
| 1757 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
| 1758 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 1759 | - return $factory->get($app); |
|
| 1760 | - } |
|
| 1761 | - |
|
| 1762 | - /** |
|
| 1763 | - * @return \OCP\Lockdown\ILockdownManager |
|
| 1764 | - */ |
|
| 1765 | - public function getLockdownManager() { |
|
| 1766 | - return $this->query('LockdownManager'); |
|
| 1767 | - } |
|
| 1768 | - |
|
| 1769 | - /** |
|
| 1770 | - * @return \OCP\Federation\ICloudIdManager |
|
| 1771 | - */ |
|
| 1772 | - public function getCloudIdManager() { |
|
| 1773 | - return $this->query(ICloudIdManager::class); |
|
| 1774 | - } |
|
| 853 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
| 854 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
| 855 | + $classExists = true; |
|
| 856 | + } else { |
|
| 857 | + $classExists = false; |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
| 861 | + return new ThemingDefaults( |
|
| 862 | + $c->getConfig(), |
|
| 863 | + $c->getL10N('theming'), |
|
| 864 | + $c->getURLGenerator(), |
|
| 865 | + new \OC_Defaults(), |
|
| 866 | + $c->getAppDataDir('theming'), |
|
| 867 | + $c->getMemCacheFactory(), |
|
| 868 | + new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
| 869 | + ); |
|
| 870 | + } |
|
| 871 | + return new \OC_Defaults(); |
|
| 872 | + }); |
|
| 873 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
| 874 | + /** @var Factory $cacheFactory */ |
|
| 875 | + $cacheFactory = $c->query(Factory::class); |
|
| 876 | + return new SCSSCacher( |
|
| 877 | + $c->getLogger(), |
|
| 878 | + $c->query(\OC\Files\AppData\Factory::class), |
|
| 879 | + $c->getURLGenerator(), |
|
| 880 | + $c->getConfig(), |
|
| 881 | + $c->getThemingDefaults(), |
|
| 882 | + \OC::$SERVERROOT, |
|
| 883 | + $cacheFactory->createLocal('SCSS') |
|
| 884 | + ); |
|
| 885 | + }); |
|
| 886 | + $this->registerService(EventDispatcher::class, function () { |
|
| 887 | + return new EventDispatcher(); |
|
| 888 | + }); |
|
| 889 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
| 890 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
| 891 | + |
|
| 892 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 893 | + // FIXME: Instantiiated here due to cyclic dependency |
|
| 894 | + $request = new Request( |
|
| 895 | + [ |
|
| 896 | + 'get' => $_GET, |
|
| 897 | + 'post' => $_POST, |
|
| 898 | + 'files' => $_FILES, |
|
| 899 | + 'server' => $_SERVER, |
|
| 900 | + 'env' => $_ENV, |
|
| 901 | + 'cookies' => $_COOKIE, |
|
| 902 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
| 903 | + ? $_SERVER['REQUEST_METHOD'] |
|
| 904 | + : null, |
|
| 905 | + ], |
|
| 906 | + $c->getSecureRandom(), |
|
| 907 | + $c->getConfig() |
|
| 908 | + ); |
|
| 909 | + |
|
| 910 | + return new CryptoWrapper( |
|
| 911 | + $c->getConfig(), |
|
| 912 | + $c->getCrypto(), |
|
| 913 | + $c->getSecureRandom(), |
|
| 914 | + $request |
|
| 915 | + ); |
|
| 916 | + }); |
|
| 917 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 918 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
| 919 | + |
|
| 920 | + return new CsrfTokenManager( |
|
| 921 | + $tokenGenerator, |
|
| 922 | + $c->query(SessionStorage::class) |
|
| 923 | + ); |
|
| 924 | + }); |
|
| 925 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 926 | + return new SessionStorage($c->getSession()); |
|
| 927 | + }); |
|
| 928 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 929 | + return new ContentSecurityPolicyManager(); |
|
| 930 | + }); |
|
| 931 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
| 932 | + |
|
| 933 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
| 934 | + return new ContentSecurityPolicyNonceManager( |
|
| 935 | + $c->getCsrfTokenManager(), |
|
| 936 | + $c->getRequest() |
|
| 937 | + ); |
|
| 938 | + }); |
|
| 939 | + |
|
| 940 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
| 941 | + $config = $c->getConfig(); |
|
| 942 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
| 943 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
| 944 | + $factory = new $factoryClass($this); |
|
| 945 | + |
|
| 946 | + $manager = new \OC\Share20\Manager( |
|
| 947 | + $c->getLogger(), |
|
| 948 | + $c->getConfig(), |
|
| 949 | + $c->getSecureRandom(), |
|
| 950 | + $c->getHasher(), |
|
| 951 | + $c->getMountManager(), |
|
| 952 | + $c->getGroupManager(), |
|
| 953 | + $c->getL10N('core'), |
|
| 954 | + $factory, |
|
| 955 | + $c->getUserManager(), |
|
| 956 | + $c->getLazyRootFolder(), |
|
| 957 | + $c->getEventDispatcher() |
|
| 958 | + ); |
|
| 959 | + |
|
| 960 | + return $manager; |
|
| 961 | + }); |
|
| 962 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
| 963 | + |
|
| 964 | + $this->registerService('SettingsManager', function(Server $c) { |
|
| 965 | + $manager = new \OC\Settings\Manager( |
|
| 966 | + $c->getLogger(), |
|
| 967 | + $c->getDatabaseConnection(), |
|
| 968 | + $c->getL10N('lib'), |
|
| 969 | + $c->getConfig(), |
|
| 970 | + $c->getEncryptionManager(), |
|
| 971 | + $c->getUserManager(), |
|
| 972 | + $c->getLockingProvider(), |
|
| 973 | + $c->getRequest(), |
|
| 974 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
| 975 | + $c->getURLGenerator() |
|
| 976 | + ); |
|
| 977 | + return $manager; |
|
| 978 | + }); |
|
| 979 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 980 | + return new \OC\Files\AppData\Factory( |
|
| 981 | + $c->getRootFolder(), |
|
| 982 | + $c->getSystemConfig() |
|
| 983 | + ); |
|
| 984 | + }); |
|
| 985 | + |
|
| 986 | + $this->registerService('LockdownManager', function (Server $c) { |
|
| 987 | + return new LockdownManager(function() use ($c) { |
|
| 988 | + return $c->getSession(); |
|
| 989 | + }); |
|
| 990 | + }); |
|
| 991 | + |
|
| 992 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 993 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
| 994 | + }); |
|
| 995 | + |
|
| 996 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 997 | + return new CloudIdManager(); |
|
| 998 | + }); |
|
| 999 | + |
|
| 1000 | + /* To trick DI since we don't extend the DIContainer here */ |
|
| 1001 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
| 1002 | + return new CleanPreviewsBackgroundJob( |
|
| 1003 | + $c->getRootFolder(), |
|
| 1004 | + $c->getLogger(), |
|
| 1005 | + $c->getJobList(), |
|
| 1006 | + new TimeFactory() |
|
| 1007 | + ); |
|
| 1008 | + }); |
|
| 1009 | + |
|
| 1010 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
| 1011 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
| 1012 | + |
|
| 1013 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
| 1014 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
| 1015 | + |
|
| 1016 | + $this->registerService(Defaults::class, function (Server $c) { |
|
| 1017 | + return new Defaults( |
|
| 1018 | + $c->getThemingDefaults() |
|
| 1019 | + ); |
|
| 1020 | + }); |
|
| 1021 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
| 1022 | + |
|
| 1023 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
| 1024 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
| 1025 | + }); |
|
| 1026 | + |
|
| 1027 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
| 1028 | + return new ShareHelper( |
|
| 1029 | + $c->query(\OCP\Share\IManager::class) |
|
| 1030 | + ); |
|
| 1031 | + }); |
|
| 1032 | + } |
|
| 1033 | + |
|
| 1034 | + /** |
|
| 1035 | + * @return \OCP\Contacts\IManager |
|
| 1036 | + */ |
|
| 1037 | + public function getContactsManager() { |
|
| 1038 | + return $this->query('ContactsManager'); |
|
| 1039 | + } |
|
| 1040 | + |
|
| 1041 | + /** |
|
| 1042 | + * @return \OC\Encryption\Manager |
|
| 1043 | + */ |
|
| 1044 | + public function getEncryptionManager() { |
|
| 1045 | + return $this->query('EncryptionManager'); |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + /** |
|
| 1049 | + * @return \OC\Encryption\File |
|
| 1050 | + */ |
|
| 1051 | + public function getEncryptionFilesHelper() { |
|
| 1052 | + return $this->query('EncryptionFileHelper'); |
|
| 1053 | + } |
|
| 1054 | + |
|
| 1055 | + /** |
|
| 1056 | + * @return \OCP\Encryption\Keys\IStorage |
|
| 1057 | + */ |
|
| 1058 | + public function getEncryptionKeyStorage() { |
|
| 1059 | + return $this->query('EncryptionKeyStorage'); |
|
| 1060 | + } |
|
| 1061 | + |
|
| 1062 | + /** |
|
| 1063 | + * The current request object holding all information about the request |
|
| 1064 | + * currently being processed is returned from this method. |
|
| 1065 | + * In case the current execution was not initiated by a web request null is returned |
|
| 1066 | + * |
|
| 1067 | + * @return \OCP\IRequest |
|
| 1068 | + */ |
|
| 1069 | + public function getRequest() { |
|
| 1070 | + return $this->query('Request'); |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + /** |
|
| 1074 | + * Returns the preview manager which can create preview images for a given file |
|
| 1075 | + * |
|
| 1076 | + * @return \OCP\IPreview |
|
| 1077 | + */ |
|
| 1078 | + public function getPreviewManager() { |
|
| 1079 | + return $this->query('PreviewManager'); |
|
| 1080 | + } |
|
| 1081 | + |
|
| 1082 | + /** |
|
| 1083 | + * Returns the tag manager which can get and set tags for different object types |
|
| 1084 | + * |
|
| 1085 | + * @see \OCP\ITagManager::load() |
|
| 1086 | + * @return \OCP\ITagManager |
|
| 1087 | + */ |
|
| 1088 | + public function getTagManager() { |
|
| 1089 | + return $this->query('TagManager'); |
|
| 1090 | + } |
|
| 1091 | + |
|
| 1092 | + /** |
|
| 1093 | + * Returns the system-tag manager |
|
| 1094 | + * |
|
| 1095 | + * @return \OCP\SystemTag\ISystemTagManager |
|
| 1096 | + * |
|
| 1097 | + * @since 9.0.0 |
|
| 1098 | + */ |
|
| 1099 | + public function getSystemTagManager() { |
|
| 1100 | + return $this->query('SystemTagManager'); |
|
| 1101 | + } |
|
| 1102 | + |
|
| 1103 | + /** |
|
| 1104 | + * Returns the system-tag object mapper |
|
| 1105 | + * |
|
| 1106 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
| 1107 | + * |
|
| 1108 | + * @since 9.0.0 |
|
| 1109 | + */ |
|
| 1110 | + public function getSystemTagObjectMapper() { |
|
| 1111 | + return $this->query('SystemTagObjectMapper'); |
|
| 1112 | + } |
|
| 1113 | + |
|
| 1114 | + /** |
|
| 1115 | + * Returns the avatar manager, used for avatar functionality |
|
| 1116 | + * |
|
| 1117 | + * @return \OCP\IAvatarManager |
|
| 1118 | + */ |
|
| 1119 | + public function getAvatarManager() { |
|
| 1120 | + return $this->query('AvatarManager'); |
|
| 1121 | + } |
|
| 1122 | + |
|
| 1123 | + /** |
|
| 1124 | + * Returns the root folder of ownCloud's data directory |
|
| 1125 | + * |
|
| 1126 | + * @return \OCP\Files\IRootFolder |
|
| 1127 | + */ |
|
| 1128 | + public function getRootFolder() { |
|
| 1129 | + return $this->query('LazyRootFolder'); |
|
| 1130 | + } |
|
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * Returns the root folder of ownCloud's data directory |
|
| 1134 | + * This is the lazy variant so this gets only initialized once it |
|
| 1135 | + * is actually used. |
|
| 1136 | + * |
|
| 1137 | + * @return \OCP\Files\IRootFolder |
|
| 1138 | + */ |
|
| 1139 | + public function getLazyRootFolder() { |
|
| 1140 | + return $this->query('LazyRootFolder'); |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + /** |
|
| 1144 | + * Returns a view to ownCloud's files folder |
|
| 1145 | + * |
|
| 1146 | + * @param string $userId user ID |
|
| 1147 | + * @return \OCP\Files\Folder|null |
|
| 1148 | + */ |
|
| 1149 | + public function getUserFolder($userId = null) { |
|
| 1150 | + if ($userId === null) { |
|
| 1151 | + $user = $this->getUserSession()->getUser(); |
|
| 1152 | + if (!$user) { |
|
| 1153 | + return null; |
|
| 1154 | + } |
|
| 1155 | + $userId = $user->getUID(); |
|
| 1156 | + } |
|
| 1157 | + $root = $this->getRootFolder(); |
|
| 1158 | + return $root->getUserFolder($userId); |
|
| 1159 | + } |
|
| 1160 | + |
|
| 1161 | + /** |
|
| 1162 | + * Returns an app-specific view in ownClouds data directory |
|
| 1163 | + * |
|
| 1164 | + * @return \OCP\Files\Folder |
|
| 1165 | + * @deprecated since 9.2.0 use IAppData |
|
| 1166 | + */ |
|
| 1167 | + public function getAppFolder() { |
|
| 1168 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1169 | + $root = $this->getRootFolder(); |
|
| 1170 | + if (!$root->nodeExists($dir)) { |
|
| 1171 | + $folder = $root->newFolder($dir); |
|
| 1172 | + } else { |
|
| 1173 | + $folder = $root->get($dir); |
|
| 1174 | + } |
|
| 1175 | + return $folder; |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + /** |
|
| 1179 | + * @return \OC\User\Manager |
|
| 1180 | + */ |
|
| 1181 | + public function getUserManager() { |
|
| 1182 | + return $this->query('UserManager'); |
|
| 1183 | + } |
|
| 1184 | + |
|
| 1185 | + /** |
|
| 1186 | + * @return \OC\Group\Manager |
|
| 1187 | + */ |
|
| 1188 | + public function getGroupManager() { |
|
| 1189 | + return $this->query('GroupManager'); |
|
| 1190 | + } |
|
| 1191 | + |
|
| 1192 | + /** |
|
| 1193 | + * @return \OC\User\Session |
|
| 1194 | + */ |
|
| 1195 | + public function getUserSession() { |
|
| 1196 | + return $this->query('UserSession'); |
|
| 1197 | + } |
|
| 1198 | + |
|
| 1199 | + /** |
|
| 1200 | + * @return \OCP\ISession |
|
| 1201 | + */ |
|
| 1202 | + public function getSession() { |
|
| 1203 | + return $this->query('UserSession')->getSession(); |
|
| 1204 | + } |
|
| 1205 | + |
|
| 1206 | + /** |
|
| 1207 | + * @param \OCP\ISession $session |
|
| 1208 | + */ |
|
| 1209 | + public function setSession(\OCP\ISession $session) { |
|
| 1210 | + $this->query(SessionStorage::class)->setSession($session); |
|
| 1211 | + $this->query('UserSession')->setSession($session); |
|
| 1212 | + $this->query(Store::class)->setSession($session); |
|
| 1213 | + } |
|
| 1214 | + |
|
| 1215 | + /** |
|
| 1216 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
| 1217 | + */ |
|
| 1218 | + public function getTwoFactorAuthManager() { |
|
| 1219 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
| 1220 | + } |
|
| 1221 | + |
|
| 1222 | + /** |
|
| 1223 | + * @return \OC\NavigationManager |
|
| 1224 | + */ |
|
| 1225 | + public function getNavigationManager() { |
|
| 1226 | + return $this->query('NavigationManager'); |
|
| 1227 | + } |
|
| 1228 | + |
|
| 1229 | + /** |
|
| 1230 | + * @return \OCP\IConfig |
|
| 1231 | + */ |
|
| 1232 | + public function getConfig() { |
|
| 1233 | + return $this->query('AllConfig'); |
|
| 1234 | + } |
|
| 1235 | + |
|
| 1236 | + /** |
|
| 1237 | + * @internal For internal use only |
|
| 1238 | + * @return \OC\SystemConfig |
|
| 1239 | + */ |
|
| 1240 | + public function getSystemConfig() { |
|
| 1241 | + return $this->query('SystemConfig'); |
|
| 1242 | + } |
|
| 1243 | + |
|
| 1244 | + /** |
|
| 1245 | + * Returns the app config manager |
|
| 1246 | + * |
|
| 1247 | + * @return \OCP\IAppConfig |
|
| 1248 | + */ |
|
| 1249 | + public function getAppConfig() { |
|
| 1250 | + return $this->query('AppConfig'); |
|
| 1251 | + } |
|
| 1252 | + |
|
| 1253 | + /** |
|
| 1254 | + * @return \OCP\L10N\IFactory |
|
| 1255 | + */ |
|
| 1256 | + public function getL10NFactory() { |
|
| 1257 | + return $this->query('L10NFactory'); |
|
| 1258 | + } |
|
| 1259 | + |
|
| 1260 | + /** |
|
| 1261 | + * get an L10N instance |
|
| 1262 | + * |
|
| 1263 | + * @param string $app appid |
|
| 1264 | + * @param string $lang |
|
| 1265 | + * @return IL10N |
|
| 1266 | + */ |
|
| 1267 | + public function getL10N($app, $lang = null) { |
|
| 1268 | + return $this->getL10NFactory()->get($app, $lang); |
|
| 1269 | + } |
|
| 1270 | + |
|
| 1271 | + /** |
|
| 1272 | + * @return \OCP\IURLGenerator |
|
| 1273 | + */ |
|
| 1274 | + public function getURLGenerator() { |
|
| 1275 | + return $this->query('URLGenerator'); |
|
| 1276 | + } |
|
| 1277 | + |
|
| 1278 | + /** |
|
| 1279 | + * @return \OCP\IHelper |
|
| 1280 | + */ |
|
| 1281 | + public function getHelper() { |
|
| 1282 | + return $this->query('AppHelper'); |
|
| 1283 | + } |
|
| 1284 | + |
|
| 1285 | + /** |
|
| 1286 | + * @return AppFetcher |
|
| 1287 | + */ |
|
| 1288 | + public function getAppFetcher() { |
|
| 1289 | + return $this->query('AppFetcher'); |
|
| 1290 | + } |
|
| 1291 | + |
|
| 1292 | + /** |
|
| 1293 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
| 1294 | + * getMemCacheFactory() instead. |
|
| 1295 | + * |
|
| 1296 | + * @return \OCP\ICache |
|
| 1297 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
| 1298 | + */ |
|
| 1299 | + public function getCache() { |
|
| 1300 | + return $this->query('UserCache'); |
|
| 1301 | + } |
|
| 1302 | + |
|
| 1303 | + /** |
|
| 1304 | + * Returns an \OCP\CacheFactory instance |
|
| 1305 | + * |
|
| 1306 | + * @return \OCP\ICacheFactory |
|
| 1307 | + */ |
|
| 1308 | + public function getMemCacheFactory() { |
|
| 1309 | + return $this->query('MemCacheFactory'); |
|
| 1310 | + } |
|
| 1311 | + |
|
| 1312 | + /** |
|
| 1313 | + * Returns an \OC\RedisFactory instance |
|
| 1314 | + * |
|
| 1315 | + * @return \OC\RedisFactory |
|
| 1316 | + */ |
|
| 1317 | + public function getGetRedisFactory() { |
|
| 1318 | + return $this->query('RedisFactory'); |
|
| 1319 | + } |
|
| 1320 | + |
|
| 1321 | + |
|
| 1322 | + /** |
|
| 1323 | + * Returns the current session |
|
| 1324 | + * |
|
| 1325 | + * @return \OCP\IDBConnection |
|
| 1326 | + */ |
|
| 1327 | + public function getDatabaseConnection() { |
|
| 1328 | + return $this->query('DatabaseConnection'); |
|
| 1329 | + } |
|
| 1330 | + |
|
| 1331 | + /** |
|
| 1332 | + * Returns the activity manager |
|
| 1333 | + * |
|
| 1334 | + * @return \OCP\Activity\IManager |
|
| 1335 | + */ |
|
| 1336 | + public function getActivityManager() { |
|
| 1337 | + return $this->query('ActivityManager'); |
|
| 1338 | + } |
|
| 1339 | + |
|
| 1340 | + /** |
|
| 1341 | + * Returns an job list for controlling background jobs |
|
| 1342 | + * |
|
| 1343 | + * @return \OCP\BackgroundJob\IJobList |
|
| 1344 | + */ |
|
| 1345 | + public function getJobList() { |
|
| 1346 | + return $this->query('JobList'); |
|
| 1347 | + } |
|
| 1348 | + |
|
| 1349 | + /** |
|
| 1350 | + * Returns a logger instance |
|
| 1351 | + * |
|
| 1352 | + * @return \OCP\ILogger |
|
| 1353 | + */ |
|
| 1354 | + public function getLogger() { |
|
| 1355 | + return $this->query('Logger'); |
|
| 1356 | + } |
|
| 1357 | + |
|
| 1358 | + /** |
|
| 1359 | + * Returns a router for generating and matching urls |
|
| 1360 | + * |
|
| 1361 | + * @return \OCP\Route\IRouter |
|
| 1362 | + */ |
|
| 1363 | + public function getRouter() { |
|
| 1364 | + return $this->query('Router'); |
|
| 1365 | + } |
|
| 1366 | + |
|
| 1367 | + /** |
|
| 1368 | + * Returns a search instance |
|
| 1369 | + * |
|
| 1370 | + * @return \OCP\ISearch |
|
| 1371 | + */ |
|
| 1372 | + public function getSearch() { |
|
| 1373 | + return $this->query('Search'); |
|
| 1374 | + } |
|
| 1375 | + |
|
| 1376 | + /** |
|
| 1377 | + * Returns a SecureRandom instance |
|
| 1378 | + * |
|
| 1379 | + * @return \OCP\Security\ISecureRandom |
|
| 1380 | + */ |
|
| 1381 | + public function getSecureRandom() { |
|
| 1382 | + return $this->query('SecureRandom'); |
|
| 1383 | + } |
|
| 1384 | + |
|
| 1385 | + /** |
|
| 1386 | + * Returns a Crypto instance |
|
| 1387 | + * |
|
| 1388 | + * @return \OCP\Security\ICrypto |
|
| 1389 | + */ |
|
| 1390 | + public function getCrypto() { |
|
| 1391 | + return $this->query('Crypto'); |
|
| 1392 | + } |
|
| 1393 | + |
|
| 1394 | + /** |
|
| 1395 | + * Returns a Hasher instance |
|
| 1396 | + * |
|
| 1397 | + * @return \OCP\Security\IHasher |
|
| 1398 | + */ |
|
| 1399 | + public function getHasher() { |
|
| 1400 | + return $this->query('Hasher'); |
|
| 1401 | + } |
|
| 1402 | + |
|
| 1403 | + /** |
|
| 1404 | + * Returns a CredentialsManager instance |
|
| 1405 | + * |
|
| 1406 | + * @return \OCP\Security\ICredentialsManager |
|
| 1407 | + */ |
|
| 1408 | + public function getCredentialsManager() { |
|
| 1409 | + return $this->query('CredentialsManager'); |
|
| 1410 | + } |
|
| 1411 | + |
|
| 1412 | + /** |
|
| 1413 | + * Returns an instance of the HTTP helper class |
|
| 1414 | + * |
|
| 1415 | + * @deprecated Use getHTTPClientService() |
|
| 1416 | + * @return \OC\HTTPHelper |
|
| 1417 | + */ |
|
| 1418 | + public function getHTTPHelper() { |
|
| 1419 | + return $this->query('HTTPHelper'); |
|
| 1420 | + } |
|
| 1421 | + |
|
| 1422 | + /** |
|
| 1423 | + * Get the certificate manager for the user |
|
| 1424 | + * |
|
| 1425 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
| 1426 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
| 1427 | + */ |
|
| 1428 | + public function getCertificateManager($userId = '') { |
|
| 1429 | + if ($userId === '') { |
|
| 1430 | + $userSession = $this->getUserSession(); |
|
| 1431 | + $user = $userSession->getUser(); |
|
| 1432 | + if (is_null($user)) { |
|
| 1433 | + return null; |
|
| 1434 | + } |
|
| 1435 | + $userId = $user->getUID(); |
|
| 1436 | + } |
|
| 1437 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
| 1438 | + } |
|
| 1439 | + |
|
| 1440 | + /** |
|
| 1441 | + * Returns an instance of the HTTP client service |
|
| 1442 | + * |
|
| 1443 | + * @return \OCP\Http\Client\IClientService |
|
| 1444 | + */ |
|
| 1445 | + public function getHTTPClientService() { |
|
| 1446 | + return $this->query('HttpClientService'); |
|
| 1447 | + } |
|
| 1448 | + |
|
| 1449 | + /** |
|
| 1450 | + * Create a new event source |
|
| 1451 | + * |
|
| 1452 | + * @return \OCP\IEventSource |
|
| 1453 | + */ |
|
| 1454 | + public function createEventSource() { |
|
| 1455 | + return new \OC_EventSource(); |
|
| 1456 | + } |
|
| 1457 | + |
|
| 1458 | + /** |
|
| 1459 | + * Get the active event logger |
|
| 1460 | + * |
|
| 1461 | + * The returned logger only logs data when debug mode is enabled |
|
| 1462 | + * |
|
| 1463 | + * @return \OCP\Diagnostics\IEventLogger |
|
| 1464 | + */ |
|
| 1465 | + public function getEventLogger() { |
|
| 1466 | + return $this->query('EventLogger'); |
|
| 1467 | + } |
|
| 1468 | + |
|
| 1469 | + /** |
|
| 1470 | + * Get the active query logger |
|
| 1471 | + * |
|
| 1472 | + * The returned logger only logs data when debug mode is enabled |
|
| 1473 | + * |
|
| 1474 | + * @return \OCP\Diagnostics\IQueryLogger |
|
| 1475 | + */ |
|
| 1476 | + public function getQueryLogger() { |
|
| 1477 | + return $this->query('QueryLogger'); |
|
| 1478 | + } |
|
| 1479 | + |
|
| 1480 | + /** |
|
| 1481 | + * Get the manager for temporary files and folders |
|
| 1482 | + * |
|
| 1483 | + * @return \OCP\ITempManager |
|
| 1484 | + */ |
|
| 1485 | + public function getTempManager() { |
|
| 1486 | + return $this->query('TempManager'); |
|
| 1487 | + } |
|
| 1488 | + |
|
| 1489 | + /** |
|
| 1490 | + * Get the app manager |
|
| 1491 | + * |
|
| 1492 | + * @return \OCP\App\IAppManager |
|
| 1493 | + */ |
|
| 1494 | + public function getAppManager() { |
|
| 1495 | + return $this->query('AppManager'); |
|
| 1496 | + } |
|
| 1497 | + |
|
| 1498 | + /** |
|
| 1499 | + * Creates a new mailer |
|
| 1500 | + * |
|
| 1501 | + * @return \OCP\Mail\IMailer |
|
| 1502 | + */ |
|
| 1503 | + public function getMailer() { |
|
| 1504 | + return $this->query('Mailer'); |
|
| 1505 | + } |
|
| 1506 | + |
|
| 1507 | + /** |
|
| 1508 | + * Get the webroot |
|
| 1509 | + * |
|
| 1510 | + * @return string |
|
| 1511 | + */ |
|
| 1512 | + public function getWebRoot() { |
|
| 1513 | + return $this->webRoot; |
|
| 1514 | + } |
|
| 1515 | + |
|
| 1516 | + /** |
|
| 1517 | + * @return \OC\OCSClient |
|
| 1518 | + */ |
|
| 1519 | + public function getOcsClient() { |
|
| 1520 | + return $this->query('OcsClient'); |
|
| 1521 | + } |
|
| 1522 | + |
|
| 1523 | + /** |
|
| 1524 | + * @return \OCP\IDateTimeZone |
|
| 1525 | + */ |
|
| 1526 | + public function getDateTimeZone() { |
|
| 1527 | + return $this->query('DateTimeZone'); |
|
| 1528 | + } |
|
| 1529 | + |
|
| 1530 | + /** |
|
| 1531 | + * @return \OCP\IDateTimeFormatter |
|
| 1532 | + */ |
|
| 1533 | + public function getDateTimeFormatter() { |
|
| 1534 | + return $this->query('DateTimeFormatter'); |
|
| 1535 | + } |
|
| 1536 | + |
|
| 1537 | + /** |
|
| 1538 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
| 1539 | + */ |
|
| 1540 | + public function getMountProviderCollection() { |
|
| 1541 | + return $this->query('MountConfigManager'); |
|
| 1542 | + } |
|
| 1543 | + |
|
| 1544 | + /** |
|
| 1545 | + * Get the IniWrapper |
|
| 1546 | + * |
|
| 1547 | + * @return IniGetWrapper |
|
| 1548 | + */ |
|
| 1549 | + public function getIniWrapper() { |
|
| 1550 | + return $this->query('IniWrapper'); |
|
| 1551 | + } |
|
| 1552 | + |
|
| 1553 | + /** |
|
| 1554 | + * @return \OCP\Command\IBus |
|
| 1555 | + */ |
|
| 1556 | + public function getCommandBus() { |
|
| 1557 | + return $this->query('AsyncCommandBus'); |
|
| 1558 | + } |
|
| 1559 | + |
|
| 1560 | + /** |
|
| 1561 | + * Get the trusted domain helper |
|
| 1562 | + * |
|
| 1563 | + * @return TrustedDomainHelper |
|
| 1564 | + */ |
|
| 1565 | + public function getTrustedDomainHelper() { |
|
| 1566 | + return $this->query('TrustedDomainHelper'); |
|
| 1567 | + } |
|
| 1568 | + |
|
| 1569 | + /** |
|
| 1570 | + * Get the locking provider |
|
| 1571 | + * |
|
| 1572 | + * @return \OCP\Lock\ILockingProvider |
|
| 1573 | + * @since 8.1.0 |
|
| 1574 | + */ |
|
| 1575 | + public function getLockingProvider() { |
|
| 1576 | + return $this->query('LockingProvider'); |
|
| 1577 | + } |
|
| 1578 | + |
|
| 1579 | + /** |
|
| 1580 | + * @return \OCP\Files\Mount\IMountManager |
|
| 1581 | + **/ |
|
| 1582 | + function getMountManager() { |
|
| 1583 | + return $this->query('MountManager'); |
|
| 1584 | + } |
|
| 1585 | + |
|
| 1586 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
| 1587 | + function getUserMountCache() { |
|
| 1588 | + return $this->query('UserMountCache'); |
|
| 1589 | + } |
|
| 1590 | + |
|
| 1591 | + /** |
|
| 1592 | + * Get the MimeTypeDetector |
|
| 1593 | + * |
|
| 1594 | + * @return \OCP\Files\IMimeTypeDetector |
|
| 1595 | + */ |
|
| 1596 | + public function getMimeTypeDetector() { |
|
| 1597 | + return $this->query('MimeTypeDetector'); |
|
| 1598 | + } |
|
| 1599 | + |
|
| 1600 | + /** |
|
| 1601 | + * Get the MimeTypeLoader |
|
| 1602 | + * |
|
| 1603 | + * @return \OCP\Files\IMimeTypeLoader |
|
| 1604 | + */ |
|
| 1605 | + public function getMimeTypeLoader() { |
|
| 1606 | + return $this->query('MimeTypeLoader'); |
|
| 1607 | + } |
|
| 1608 | + |
|
| 1609 | + /** |
|
| 1610 | + * Get the manager of all the capabilities |
|
| 1611 | + * |
|
| 1612 | + * @return \OC\CapabilitiesManager |
|
| 1613 | + */ |
|
| 1614 | + public function getCapabilitiesManager() { |
|
| 1615 | + return $this->query('CapabilitiesManager'); |
|
| 1616 | + } |
|
| 1617 | + |
|
| 1618 | + /** |
|
| 1619 | + * Get the EventDispatcher |
|
| 1620 | + * |
|
| 1621 | + * @return EventDispatcherInterface |
|
| 1622 | + * @since 8.2.0 |
|
| 1623 | + */ |
|
| 1624 | + public function getEventDispatcher() { |
|
| 1625 | + return $this->query('EventDispatcher'); |
|
| 1626 | + } |
|
| 1627 | + |
|
| 1628 | + /** |
|
| 1629 | + * Get the Notification Manager |
|
| 1630 | + * |
|
| 1631 | + * @return \OCP\Notification\IManager |
|
| 1632 | + * @since 8.2.0 |
|
| 1633 | + */ |
|
| 1634 | + public function getNotificationManager() { |
|
| 1635 | + return $this->query('NotificationManager'); |
|
| 1636 | + } |
|
| 1637 | + |
|
| 1638 | + /** |
|
| 1639 | + * @return \OCP\Comments\ICommentsManager |
|
| 1640 | + */ |
|
| 1641 | + public function getCommentsManager() { |
|
| 1642 | + return $this->query('CommentsManager'); |
|
| 1643 | + } |
|
| 1644 | + |
|
| 1645 | + /** |
|
| 1646 | + * @return \OCA\Theming\ThemingDefaults |
|
| 1647 | + */ |
|
| 1648 | + public function getThemingDefaults() { |
|
| 1649 | + return $this->query('ThemingDefaults'); |
|
| 1650 | + } |
|
| 1651 | + |
|
| 1652 | + /** |
|
| 1653 | + * @return \OC\IntegrityCheck\Checker |
|
| 1654 | + */ |
|
| 1655 | + public function getIntegrityCodeChecker() { |
|
| 1656 | + return $this->query('IntegrityCodeChecker'); |
|
| 1657 | + } |
|
| 1658 | + |
|
| 1659 | + /** |
|
| 1660 | + * @return \OC\Session\CryptoWrapper |
|
| 1661 | + */ |
|
| 1662 | + public function getSessionCryptoWrapper() { |
|
| 1663 | + return $this->query('CryptoWrapper'); |
|
| 1664 | + } |
|
| 1665 | + |
|
| 1666 | + /** |
|
| 1667 | + * @return CsrfTokenManager |
|
| 1668 | + */ |
|
| 1669 | + public function getCsrfTokenManager() { |
|
| 1670 | + return $this->query('CsrfTokenManager'); |
|
| 1671 | + } |
|
| 1672 | + |
|
| 1673 | + /** |
|
| 1674 | + * @return Throttler |
|
| 1675 | + */ |
|
| 1676 | + public function getBruteForceThrottler() { |
|
| 1677 | + return $this->query('Throttler'); |
|
| 1678 | + } |
|
| 1679 | + |
|
| 1680 | + /** |
|
| 1681 | + * @return IContentSecurityPolicyManager |
|
| 1682 | + */ |
|
| 1683 | + public function getContentSecurityPolicyManager() { |
|
| 1684 | + return $this->query('ContentSecurityPolicyManager'); |
|
| 1685 | + } |
|
| 1686 | + |
|
| 1687 | + /** |
|
| 1688 | + * @return ContentSecurityPolicyNonceManager |
|
| 1689 | + */ |
|
| 1690 | + public function getContentSecurityPolicyNonceManager() { |
|
| 1691 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + /** |
|
| 1695 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1696 | + * |
|
| 1697 | + * @return \OCA\Files_External\Service\BackendService |
|
| 1698 | + */ |
|
| 1699 | + public function getStoragesBackendService() { |
|
| 1700 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
| 1701 | + } |
|
| 1702 | + |
|
| 1703 | + /** |
|
| 1704 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1705 | + * |
|
| 1706 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
| 1707 | + */ |
|
| 1708 | + public function getGlobalStoragesService() { |
|
| 1709 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
| 1710 | + } |
|
| 1711 | + |
|
| 1712 | + /** |
|
| 1713 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1714 | + * |
|
| 1715 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
| 1716 | + */ |
|
| 1717 | + public function getUserGlobalStoragesService() { |
|
| 1718 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
| 1719 | + } |
|
| 1720 | + |
|
| 1721 | + /** |
|
| 1722 | + * Not a public API as of 8.2, wait for 9.0 |
|
| 1723 | + * |
|
| 1724 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
| 1725 | + */ |
|
| 1726 | + public function getUserStoragesService() { |
|
| 1727 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
| 1728 | + } |
|
| 1729 | + |
|
| 1730 | + /** |
|
| 1731 | + * @return \OCP\Share\IManager |
|
| 1732 | + */ |
|
| 1733 | + public function getShareManager() { |
|
| 1734 | + return $this->query('ShareManager'); |
|
| 1735 | + } |
|
| 1736 | + |
|
| 1737 | + /** |
|
| 1738 | + * Returns the LDAP Provider |
|
| 1739 | + * |
|
| 1740 | + * @return \OCP\LDAP\ILDAPProvider |
|
| 1741 | + */ |
|
| 1742 | + public function getLDAPProvider() { |
|
| 1743 | + return $this->query('LDAPProvider'); |
|
| 1744 | + } |
|
| 1745 | + |
|
| 1746 | + /** |
|
| 1747 | + * @return \OCP\Settings\IManager |
|
| 1748 | + */ |
|
| 1749 | + public function getSettingsManager() { |
|
| 1750 | + return $this->query('SettingsManager'); |
|
| 1751 | + } |
|
| 1752 | + |
|
| 1753 | + /** |
|
| 1754 | + * @return \OCP\Files\IAppData |
|
| 1755 | + */ |
|
| 1756 | + public function getAppDataDir($app) { |
|
| 1757 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
| 1758 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
| 1759 | + return $factory->get($app); |
|
| 1760 | + } |
|
| 1761 | + |
|
| 1762 | + /** |
|
| 1763 | + * @return \OCP\Lockdown\ILockdownManager |
|
| 1764 | + */ |
|
| 1765 | + public function getLockdownManager() { |
|
| 1766 | + return $this->query('LockdownManager'); |
|
| 1767 | + } |
|
| 1768 | + |
|
| 1769 | + /** |
|
| 1770 | + * @return \OCP\Federation\ICloudIdManager |
|
| 1771 | + */ |
|
| 1772 | + public function getCloudIdManager() { |
|
| 1773 | + return $this->query(ICloudIdManager::class); |
|
| 1774 | + } |
|
| 1775 | 1775 | } |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | |
| 150 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
| 150 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
| 151 | 151 | return new PreviewManager( |
| 152 | 152 | $c->getConfig(), |
| 153 | 153 | $c->getRootFolder(), |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | }); |
| 159 | 159 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
| 160 | 160 | |
| 161 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
| 161 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
| 162 | 162 | return new \OC\Preview\Watcher( |
| 163 | 163 | $c->getAppDataDir('preview') |
| 164 | 164 | ); |
| 165 | 165 | }); |
| 166 | 166 | |
| 167 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
| 167 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
| 168 | 168 | $view = new View(); |
| 169 | 169 | $util = new Encryption\Util( |
| 170 | 170 | $view, |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | ); |
| 183 | 183 | }); |
| 184 | 184 | |
| 185 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
| 185 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
| 186 | 186 | $util = new Encryption\Util( |
| 187 | 187 | new View(), |
| 188 | 188 | $c->getUserManager(), |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | ); |
| 197 | 197 | }); |
| 198 | 198 | |
| 199 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
| 199 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
| 200 | 200 | $view = new View(); |
| 201 | 201 | $util = new Encryption\Util( |
| 202 | 202 | $view, |
@@ -207,32 +207,32 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | return new Encryption\Keys\Storage($view, $util); |
| 209 | 209 | }); |
| 210 | - $this->registerService('TagMapper', function (Server $c) { |
|
| 210 | + $this->registerService('TagMapper', function(Server $c) { |
|
| 211 | 211 | return new TagMapper($c->getDatabaseConnection()); |
| 212 | 212 | }); |
| 213 | 213 | |
| 214 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
| 214 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
| 215 | 215 | $tagMapper = $c->query('TagMapper'); |
| 216 | 216 | return new TagManager($tagMapper, $c->getUserSession()); |
| 217 | 217 | }); |
| 218 | 218 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
| 219 | 219 | |
| 220 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 220 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
| 221 | 221 | $config = $c->getConfig(); |
| 222 | 222 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
| 223 | 223 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
| 224 | 224 | $factory = new $factoryClass($this); |
| 225 | 225 | return $factory; |
| 226 | 226 | }); |
| 227 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
| 227 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
| 228 | 228 | return $c->query('SystemTagManagerFactory')->getManager(); |
| 229 | 229 | }); |
| 230 | 230 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
| 231 | 231 | |
| 232 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
| 232 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
| 233 | 233 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
| 234 | 234 | }); |
| 235 | - $this->registerService('RootFolder', function (Server $c) { |
|
| 235 | + $this->registerService('RootFolder', function(Server $c) { |
|
| 236 | 236 | $manager = \OC\Files\Filesystem::getMountManager(null); |
| 237 | 237 | $view = new View(); |
| 238 | 238 | $root = new Root( |
@@ -260,30 +260,30 @@ discard block |
||
| 260 | 260 | }); |
| 261 | 261 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
| 262 | 262 | |
| 263 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
| 263 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
| 264 | 264 | $config = $c->getConfig(); |
| 265 | 265 | return new \OC\User\Manager($config); |
| 266 | 266 | }); |
| 267 | 267 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
| 268 | 268 | |
| 269 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
| 269 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
| 270 | 270 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
| 271 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
| 271 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
| 272 | 272 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
| 273 | 273 | }); |
| 274 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
| 274 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
| 275 | 275 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
| 276 | 276 | }); |
| 277 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
| 277 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
| 278 | 278 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
| 279 | 279 | }); |
| 280 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
| 280 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
| 281 | 281 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
| 282 | 282 | }); |
| 283 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 283 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 284 | 284 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
| 285 | 285 | }); |
| 286 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
| 286 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
| 287 | 287 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
| 288 | 288 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
| 289 | 289 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -303,11 +303,11 @@ discard block |
||
| 303 | 303 | return new Store($session, $logger, $tokenProvider); |
| 304 | 304 | }); |
| 305 | 305 | $this->registerAlias(IStore::class, Store::class); |
| 306 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
| 306 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
| 307 | 307 | $dbConnection = $c->getDatabaseConnection(); |
| 308 | 308 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
| 309 | 309 | }); |
| 310 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
| 310 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
| 311 | 311 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
| 312 | 312 | $crypto = $c->getCrypto(); |
| 313 | 313 | $config = $c->getConfig(); |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | }); |
| 318 | 318 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
| 319 | 319 | |
| 320 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
| 320 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
| 321 | 321 | $manager = $c->getUserManager(); |
| 322 | 322 | $session = new \OC\Session\Memory(''); |
| 323 | 323 | $timeFactory = new TimeFactory(); |
@@ -330,40 +330,40 @@ discard block |
||
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
| 333 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
| 333 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
| 334 | 334 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
| 335 | 335 | }); |
| 336 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
| 336 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
| 337 | 337 | /** @var $user \OC\User\User */ |
| 338 | 338 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
| 339 | 339 | }); |
| 340 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
| 340 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
| 341 | 341 | /** @var $user \OC\User\User */ |
| 342 | 342 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
| 343 | 343 | }); |
| 344 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
| 344 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
| 345 | 345 | /** @var $user \OC\User\User */ |
| 346 | 346 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
| 347 | 347 | }); |
| 348 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 348 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
| 349 | 349 | /** @var $user \OC\User\User */ |
| 350 | 350 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
| 351 | 351 | }); |
| 352 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 352 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
| 353 | 353 | /** @var $user \OC\User\User */ |
| 354 | 354 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
| 355 | 355 | }); |
| 356 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
| 356 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
| 357 | 357 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
| 358 | 358 | }); |
| 359 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
| 359 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
| 360 | 360 | /** @var $user \OC\User\User */ |
| 361 | 361 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
| 362 | 362 | }); |
| 363 | - $userSession->listen('\OC\User', 'logout', function () { |
|
| 363 | + $userSession->listen('\OC\User', 'logout', function() { |
|
| 364 | 364 | \OC_Hook::emit('OC_User', 'logout', array()); |
| 365 | 365 | }); |
| 366 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
| 366 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) { |
|
| 367 | 367 | /** @var $user \OC\User\User */ |
| 368 | 368 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
| 369 | 369 | }); |
@@ -371,14 +371,14 @@ discard block |
||
| 371 | 371 | }); |
| 372 | 372 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
| 373 | 373 | |
| 374 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
| 374 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
| 375 | 375 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
| 376 | 376 | }); |
| 377 | 377 | |
| 378 | 378 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
| 379 | 379 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
| 380 | 380 | |
| 381 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
| 381 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
| 382 | 382 | return new \OC\AllConfig( |
| 383 | 383 | $c->getSystemConfig() |
| 384 | 384 | ); |
@@ -386,17 +386,17 @@ discard block |
||
| 386 | 386 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
| 387 | 387 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
| 388 | 388 | |
| 389 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
| 389 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
| 390 | 390 | return new \OC\SystemConfig($config); |
| 391 | 391 | }); |
| 392 | 392 | |
| 393 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
| 393 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
| 394 | 394 | return new \OC\AppConfig($c->getDatabaseConnection()); |
| 395 | 395 | }); |
| 396 | 396 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
| 397 | 397 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
| 398 | 398 | |
| 399 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
| 399 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
| 400 | 400 | return new \OC\L10N\Factory( |
| 401 | 401 | $c->getConfig(), |
| 402 | 402 | $c->getRequest(), |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | }); |
| 407 | 407 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
| 408 | 408 | |
| 409 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
| 409 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
| 410 | 410 | $config = $c->getConfig(); |
| 411 | 411 | $cacheFactory = $c->getMemCacheFactory(); |
| 412 | 412 | return new \OC\URLGenerator( |
@@ -416,10 +416,10 @@ discard block |
||
| 416 | 416 | }); |
| 417 | 417 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
| 418 | 418 | |
| 419 | - $this->registerService('AppHelper', function ($c) { |
|
| 419 | + $this->registerService('AppHelper', function($c) { |
|
| 420 | 420 | return new \OC\AppHelper(); |
| 421 | 421 | }); |
| 422 | - $this->registerService('AppFetcher', function ($c) { |
|
| 422 | + $this->registerService('AppFetcher', function($c) { |
|
| 423 | 423 | return new AppFetcher( |
| 424 | 424 | $this->getAppDataDir('appstore'), |
| 425 | 425 | $this->getHTTPClientService(), |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | $this->getConfig() |
| 428 | 428 | ); |
| 429 | 429 | }); |
| 430 | - $this->registerService('CategoryFetcher', function ($c) { |
|
| 430 | + $this->registerService('CategoryFetcher', function($c) { |
|
| 431 | 431 | return new CategoryFetcher( |
| 432 | 432 | $this->getAppDataDir('appstore'), |
| 433 | 433 | $this->getHTTPClientService(), |
@@ -436,21 +436,21 @@ discard block |
||
| 436 | 436 | ); |
| 437 | 437 | }); |
| 438 | 438 | |
| 439 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
| 439 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
| 440 | 440 | return new Cache\File(); |
| 441 | 441 | }); |
| 442 | 442 | $this->registerAlias('UserCache', \OCP\ICache::class); |
| 443 | 443 | |
| 444 | - $this->registerService(Factory::class, function (Server $c) { |
|
| 444 | + $this->registerService(Factory::class, function(Server $c) { |
|
| 445 | 445 | $config = $c->getConfig(); |
| 446 | 446 | |
| 447 | 447 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
| 448 | 448 | $v = \OC_App::getAppVersions(); |
| 449 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
| 449 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
| 450 | 450 | $version = implode(',', $v); |
| 451 | 451 | $instanceId = \OC_Util::getInstanceId(); |
| 452 | 452 | $path = \OC::$SERVERROOT; |
| 453 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
| 453 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
| 454 | 454 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
| 455 | 455 | $config->getSystemValue('memcache.local', null), |
| 456 | 456 | $config->getSystemValue('memcache.distributed', null), |
@@ -467,12 +467,12 @@ discard block |
||
| 467 | 467 | $this->registerAlias('MemCacheFactory', Factory::class); |
| 468 | 468 | $this->registerAlias(ICacheFactory::class, Factory::class); |
| 469 | 469 | |
| 470 | - $this->registerService('RedisFactory', function (Server $c) { |
|
| 470 | + $this->registerService('RedisFactory', function(Server $c) { |
|
| 471 | 471 | $systemConfig = $c->getSystemConfig(); |
| 472 | 472 | return new RedisFactory($systemConfig); |
| 473 | 473 | }); |
| 474 | 474 | |
| 475 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
| 475 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
| 476 | 476 | return new \OC\Activity\Manager( |
| 477 | 477 | $c->getRequest(), |
| 478 | 478 | $c->getUserSession(), |
@@ -482,14 +482,14 @@ discard block |
||
| 482 | 482 | }); |
| 483 | 483 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
| 484 | 484 | |
| 485 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
| 485 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
| 486 | 486 | return new \OC\Activity\EventMerger( |
| 487 | 487 | $c->getL10N('lib') |
| 488 | 488 | ); |
| 489 | 489 | }); |
| 490 | 490 | $this->registerAlias(IValidator::class, Validator::class); |
| 491 | 491 | |
| 492 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
| 492 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
| 493 | 493 | return new AvatarManager( |
| 494 | 494 | $c->getUserManager(), |
| 495 | 495 | $c->getAppDataDir('avatar'), |
@@ -500,7 +500,7 @@ discard block |
||
| 500 | 500 | }); |
| 501 | 501 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
| 502 | 502 | |
| 503 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
| 503 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
| 504 | 504 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
| 505 | 505 | $logger = Log::getLogClass($logType); |
| 506 | 506 | call_user_func(array($logger, 'init')); |
@@ -509,7 +509,7 @@ discard block |
||
| 509 | 509 | }); |
| 510 | 510 | $this->registerAlias('Logger', \OCP\ILogger::class); |
| 511 | 511 | |
| 512 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
| 512 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
| 513 | 513 | $config = $c->getConfig(); |
| 514 | 514 | return new \OC\BackgroundJob\JobList( |
| 515 | 515 | $c->getDatabaseConnection(), |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | }); |
| 520 | 520 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
| 521 | 521 | |
| 522 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
| 522 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
| 523 | 523 | $cacheFactory = $c->getMemCacheFactory(); |
| 524 | 524 | $logger = $c->getLogger(); |
| 525 | 525 | if ($cacheFactory->isAvailable()) { |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | }); |
| 532 | 532 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
| 533 | 533 | |
| 534 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
| 534 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
| 535 | 535 | return new Search(); |
| 536 | 536 | }); |
| 537 | 537 | $this->registerAlias('Search', \OCP\ISearch::class); |
@@ -551,27 +551,27 @@ discard block |
||
| 551 | 551 | ); |
| 552 | 552 | }); |
| 553 | 553 | |
| 554 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
| 554 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
| 555 | 555 | return new SecureRandom(); |
| 556 | 556 | }); |
| 557 | 557 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
| 558 | 558 | |
| 559 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
| 559 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
| 560 | 560 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
| 561 | 561 | }); |
| 562 | 562 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
| 563 | 563 | |
| 564 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
| 564 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
| 565 | 565 | return new Hasher($c->getConfig()); |
| 566 | 566 | }); |
| 567 | 567 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
| 568 | 568 | |
| 569 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
| 569 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
| 570 | 570 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
| 571 | 571 | }); |
| 572 | 572 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
| 573 | 573 | |
| 574 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
| 574 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
| 575 | 575 | $systemConfig = $c->getSystemConfig(); |
| 576 | 576 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
| 577 | 577 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | }); |
| 586 | 586 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
| 587 | 587 | |
| 588 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
| 588 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
| 589 | 589 | $config = $c->getConfig(); |
| 590 | 590 | return new HTTPHelper( |
| 591 | 591 | $config, |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | ); |
| 594 | 594 | }); |
| 595 | 595 | |
| 596 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
| 596 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
| 597 | 597 | $user = \OC_User::getUser(); |
| 598 | 598 | $uid = $user ? $user : null; |
| 599 | 599 | return new ClientService( |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | ); |
| 603 | 603 | }); |
| 604 | 604 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
| 605 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
| 605 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
| 606 | 606 | $eventLogger = new EventLogger(); |
| 607 | 607 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 608 | 608 | // In debug mode, module is being activated by default |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | }); |
| 613 | 613 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
| 614 | 614 | |
| 615 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
| 615 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
| 616 | 616 | $queryLogger = new QueryLogger(); |
| 617 | 617 | if ($c->getSystemConfig()->getValue('debug', false)) { |
| 618 | 618 | // In debug mode, module is being activated by default |
@@ -622,7 +622,7 @@ discard block |
||
| 622 | 622 | }); |
| 623 | 623 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
| 624 | 624 | |
| 625 | - $this->registerService(TempManager::class, function (Server $c) { |
|
| 625 | + $this->registerService(TempManager::class, function(Server $c) { |
|
| 626 | 626 | return new TempManager( |
| 627 | 627 | $c->getLogger(), |
| 628 | 628 | $c->getConfig() |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | $this->registerAlias('TempManager', TempManager::class); |
| 632 | 632 | $this->registerAlias(ITempManager::class, TempManager::class); |
| 633 | 633 | |
| 634 | - $this->registerService(AppManager::class, function (Server $c) { |
|
| 634 | + $this->registerService(AppManager::class, function(Server $c) { |
|
| 635 | 635 | return new \OC\App\AppManager( |
| 636 | 636 | $c->getUserSession(), |
| 637 | 637 | $c->getAppConfig(), |
@@ -643,7 +643,7 @@ discard block |
||
| 643 | 643 | $this->registerAlias('AppManager', AppManager::class); |
| 644 | 644 | $this->registerAlias(IAppManager::class, AppManager::class); |
| 645 | 645 | |
| 646 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
| 646 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
| 647 | 647 | return new DateTimeZone( |
| 648 | 648 | $c->getConfig(), |
| 649 | 649 | $c->getSession() |
@@ -651,7 +651,7 @@ discard block |
||
| 651 | 651 | }); |
| 652 | 652 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
| 653 | 653 | |
| 654 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
| 654 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
| 655 | 655 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
| 656 | 656 | |
| 657 | 657 | return new DateTimeFormatter( |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | }); |
| 662 | 662 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
| 663 | 663 | |
| 664 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
| 664 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
| 665 | 665 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
| 666 | 666 | $listener = new UserMountCacheListener($mountCache); |
| 667 | 667 | $listener->listen($c->getUserManager()); |
@@ -669,10 +669,10 @@ discard block |
||
| 669 | 669 | }); |
| 670 | 670 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
| 671 | 671 | |
| 672 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
| 672 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
| 673 | 673 | $loader = \OC\Files\Filesystem::getLoader(); |
| 674 | 674 | $mountCache = $c->query('UserMountCache'); |
| 675 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 675 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
| 676 | 676 | |
| 677 | 677 | // builtin providers |
| 678 | 678 | |
@@ -685,14 +685,14 @@ discard block |
||
| 685 | 685 | }); |
| 686 | 686 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
| 687 | 687 | |
| 688 | - $this->registerService('IniWrapper', function ($c) { |
|
| 688 | + $this->registerService('IniWrapper', function($c) { |
|
| 689 | 689 | return new IniGetWrapper(); |
| 690 | 690 | }); |
| 691 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
| 691 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
| 692 | 692 | $jobList = $c->getJobList(); |
| 693 | 693 | return new AsyncBus($jobList); |
| 694 | 694 | }); |
| 695 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
| 695 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
| 696 | 696 | return new TrustedDomainHelper($this->getConfig()); |
| 697 | 697 | }); |
| 698 | 698 | $this->registerService('Throttler', function(Server $c) { |
@@ -703,10 +703,10 @@ discard block |
||
| 703 | 703 | $c->getConfig() |
| 704 | 704 | ); |
| 705 | 705 | }); |
| 706 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
| 706 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
| 707 | 707 | // IConfig and IAppManager requires a working database. This code |
| 708 | 708 | // might however be called when ownCloud is not yet setup. |
| 709 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 709 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 710 | 710 | $config = $c->getConfig(); |
| 711 | 711 | $appManager = $c->getAppManager(); |
| 712 | 712 | } else { |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | $c->getTempManager() |
| 725 | 725 | ); |
| 726 | 726 | }); |
| 727 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
| 727 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
| 728 | 728 | if (isset($this['urlParams'])) { |
| 729 | 729 | $urlParams = $this['urlParams']; |
| 730 | 730 | } else { |
@@ -760,7 +760,7 @@ discard block |
||
| 760 | 760 | }); |
| 761 | 761 | $this->registerAlias('Request', \OCP\IRequest::class); |
| 762 | 762 | |
| 763 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
| 763 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
| 764 | 764 | return new Mailer( |
| 765 | 765 | $c->getConfig(), |
| 766 | 766 | $c->getLogger(), |
@@ -774,14 +774,14 @@ discard block |
||
| 774 | 774 | $this->registerService('LDAPProvider', function(Server $c) { |
| 775 | 775 | $config = $c->getConfig(); |
| 776 | 776 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
| 777 | - if(is_null($factoryClass)) { |
|
| 777 | + if (is_null($factoryClass)) { |
|
| 778 | 778 | throw new \Exception('ldapProviderFactory not set'); |
| 779 | 779 | } |
| 780 | 780 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
| 781 | 781 | $factory = new $factoryClass($this); |
| 782 | 782 | return $factory->getLDAPProvider(); |
| 783 | 783 | }); |
| 784 | - $this->registerService('LockingProvider', function (Server $c) { |
|
| 784 | + $this->registerService('LockingProvider', function(Server $c) { |
|
| 785 | 785 | $ini = $c->getIniWrapper(); |
| 786 | 786 | $config = $c->getConfig(); |
| 787 | 787 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -797,37 +797,37 @@ discard block |
||
| 797 | 797 | return new NoopLockingProvider(); |
| 798 | 798 | }); |
| 799 | 799 | |
| 800 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
| 800 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
| 801 | 801 | return new \OC\Files\Mount\Manager(); |
| 802 | 802 | }); |
| 803 | 803 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
| 804 | 804 | |
| 805 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
| 805 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
| 806 | 806 | return new \OC\Files\Type\Detection( |
| 807 | 807 | $c->getURLGenerator(), |
| 808 | 808 | \OC::$configDir, |
| 809 | - \OC::$SERVERROOT . '/resources/config/' |
|
| 809 | + \OC::$SERVERROOT.'/resources/config/' |
|
| 810 | 810 | ); |
| 811 | 811 | }); |
| 812 | 812 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
| 813 | 813 | |
| 814 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
| 814 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
| 815 | 815 | return new \OC\Files\Type\Loader( |
| 816 | 816 | $c->getDatabaseConnection() |
| 817 | 817 | ); |
| 818 | 818 | }); |
| 819 | 819 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
| 820 | 820 | |
| 821 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
| 821 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
| 822 | 822 | return new Manager( |
| 823 | 823 | $c->query(IValidator::class) |
| 824 | 824 | ); |
| 825 | 825 | }); |
| 826 | 826 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
| 827 | 827 | |
| 828 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
| 828 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
| 829 | 829 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
| 830 | - $manager->registerCapability(function () use ($c) { |
|
| 830 | + $manager->registerCapability(function() use ($c) { |
|
| 831 | 831 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
| 832 | 832 | }); |
| 833 | 833 | return $manager; |
@@ -883,13 +883,13 @@ discard block |
||
| 883 | 883 | $cacheFactory->createLocal('SCSS') |
| 884 | 884 | ); |
| 885 | 885 | }); |
| 886 | - $this->registerService(EventDispatcher::class, function () { |
|
| 886 | + $this->registerService(EventDispatcher::class, function() { |
|
| 887 | 887 | return new EventDispatcher(); |
| 888 | 888 | }); |
| 889 | 889 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
| 890 | 890 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
| 891 | 891 | |
| 892 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
| 892 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
| 893 | 893 | // FIXME: Instantiiated here due to cyclic dependency |
| 894 | 894 | $request = new Request( |
| 895 | 895 | [ |
@@ -914,7 +914,7 @@ discard block |
||
| 914 | 914 | $request |
| 915 | 915 | ); |
| 916 | 916 | }); |
| 917 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
| 917 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
| 918 | 918 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
| 919 | 919 | |
| 920 | 920 | return new CsrfTokenManager( |
@@ -922,10 +922,10 @@ discard block |
||
| 922 | 922 | $c->query(SessionStorage::class) |
| 923 | 923 | ); |
| 924 | 924 | }); |
| 925 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
| 925 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
| 926 | 926 | return new SessionStorage($c->getSession()); |
| 927 | 927 | }); |
| 928 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
| 928 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
| 929 | 929 | return new ContentSecurityPolicyManager(); |
| 930 | 930 | }); |
| 931 | 931 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -976,29 +976,29 @@ discard block |
||
| 976 | 976 | ); |
| 977 | 977 | return $manager; |
| 978 | 978 | }); |
| 979 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
| 979 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
| 980 | 980 | return new \OC\Files\AppData\Factory( |
| 981 | 981 | $c->getRootFolder(), |
| 982 | 982 | $c->getSystemConfig() |
| 983 | 983 | ); |
| 984 | 984 | }); |
| 985 | 985 | |
| 986 | - $this->registerService('LockdownManager', function (Server $c) { |
|
| 986 | + $this->registerService('LockdownManager', function(Server $c) { |
|
| 987 | 987 | return new LockdownManager(function() use ($c) { |
| 988 | 988 | return $c->getSession(); |
| 989 | 989 | }); |
| 990 | 990 | }); |
| 991 | 991 | |
| 992 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
| 992 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
| 993 | 993 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
| 994 | 994 | }); |
| 995 | 995 | |
| 996 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
| 996 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
| 997 | 997 | return new CloudIdManager(); |
| 998 | 998 | }); |
| 999 | 999 | |
| 1000 | 1000 | /* To trick DI since we don't extend the DIContainer here */ |
| 1001 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
| 1001 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
| 1002 | 1002 | return new CleanPreviewsBackgroundJob( |
| 1003 | 1003 | $c->getRootFolder(), |
| 1004 | 1004 | $c->getLogger(), |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
| 1014 | 1014 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
| 1015 | 1015 | |
| 1016 | - $this->registerService(Defaults::class, function (Server $c) { |
|
| 1016 | + $this->registerService(Defaults::class, function(Server $c) { |
|
| 1017 | 1017 | return new Defaults( |
| 1018 | 1018 | $c->getThemingDefaults() |
| 1019 | 1019 | ); |
@@ -1165,7 +1165,7 @@ discard block |
||
| 1165 | 1165 | * @deprecated since 9.2.0 use IAppData |
| 1166 | 1166 | */ |
| 1167 | 1167 | public function getAppFolder() { |
| 1168 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
| 1168 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
| 1169 | 1169 | $root = $this->getRootFolder(); |
| 1170 | 1170 | if (!$root->nodeExists($dir)) { |
| 1171 | 1171 | $folder = $root->newFolder($dir); |
@@ -35,55 +35,55 @@ |
||
| 35 | 35 | * @since 8.0.0 |
| 36 | 36 | */ |
| 37 | 37 | interface IEventLogger { |
| 38 | - /** |
|
| 39 | - * Mark the start of an event setting its ID $id and providing event description $description. |
|
| 40 | - * |
|
| 41 | - * @param string $id |
|
| 42 | - * @param string $description |
|
| 43 | - * @since 8.0.0 |
|
| 44 | - */ |
|
| 45 | - public function start($id, $description); |
|
| 38 | + /** |
|
| 39 | + * Mark the start of an event setting its ID $id and providing event description $description. |
|
| 40 | + * |
|
| 41 | + * @param string $id |
|
| 42 | + * @param string $description |
|
| 43 | + * @since 8.0.0 |
|
| 44 | + */ |
|
| 45 | + public function start($id, $description); |
|
| 46 | 46 | |
| 47 | - /** |
|
| 48 | - * Mark the end of an event with specific ID $id, marked by start() method. |
|
| 49 | - * Ending event should store \OCP\Diagnostics\IEvent to |
|
| 50 | - * be returned with getEvents() method. |
|
| 51 | - * |
|
| 52 | - * @param string $id |
|
| 53 | - * @since 8.0.0 |
|
| 54 | - */ |
|
| 55 | - public function end($id); |
|
| 47 | + /** |
|
| 48 | + * Mark the end of an event with specific ID $id, marked by start() method. |
|
| 49 | + * Ending event should store \OCP\Diagnostics\IEvent to |
|
| 50 | + * be returned with getEvents() method. |
|
| 51 | + * |
|
| 52 | + * @param string $id |
|
| 53 | + * @since 8.0.0 |
|
| 54 | + */ |
|
| 55 | + public function end($id); |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Mark the start and the end of an event with specific ID $id and description $description, |
|
| 59 | - * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
| 60 | - * Logging event should store \OCP\Diagnostics\IEvent to |
|
| 61 | - * be returned with getEvents() method. |
|
| 62 | - * |
|
| 63 | - * @param string $id |
|
| 64 | - * @param string $description |
|
| 65 | - * @param float $start |
|
| 66 | - * @param float $end |
|
| 67 | - * @since 8.0.0 |
|
| 68 | - */ |
|
| 69 | - public function log($id, $description, $start, $end); |
|
| 57 | + /** |
|
| 58 | + * Mark the start and the end of an event with specific ID $id and description $description, |
|
| 59 | + * explicitly marking start and end of the event, represented by $start and $end timestamps. |
|
| 60 | + * Logging event should store \OCP\Diagnostics\IEvent to |
|
| 61 | + * be returned with getEvents() method. |
|
| 62 | + * |
|
| 63 | + * @param string $id |
|
| 64 | + * @param string $description |
|
| 65 | + * @param float $start |
|
| 66 | + * @param float $end |
|
| 67 | + * @since 8.0.0 |
|
| 68 | + */ |
|
| 69 | + public function log($id, $description, $start, $end); |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
| 73 | - * start()/end() or log() methods |
|
| 74 | - * |
|
| 75 | - * @return \OCP\Diagnostics\IEvent[] |
|
| 76 | - * @since 8.0.0 |
|
| 77 | - */ |
|
| 78 | - public function getEvents(); |
|
| 71 | + /** |
|
| 72 | + * This method should return all \OCP\Diagnostics\IEvent objects stored using |
|
| 73 | + * start()/end() or log() methods |
|
| 74 | + * |
|
| 75 | + * @return \OCP\Diagnostics\IEvent[] |
|
| 76 | + * @since 8.0.0 |
|
| 77 | + */ |
|
| 78 | + public function getEvents(); |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * Activate the module for the duration of the request. Deactivated module |
|
| 82 | - * does not create and store \OCP\Diagnostics\IEvent objects. |
|
| 83 | - * Only activated module should create and store objects to be |
|
| 84 | - * returned with getEvents() call. |
|
| 85 | - * |
|
| 86 | - * @since 12.0.0 |
|
| 87 | - */ |
|
| 88 | - public function activate(); |
|
| 80 | + /** |
|
| 81 | + * Activate the module for the duration of the request. Deactivated module |
|
| 82 | + * does not create and store \OCP\Diagnostics\IEvent objects. |
|
| 83 | + * Only activated module should create and store objects to be |
|
| 84 | + * returned with getEvents() call. |
|
| 85 | + * |
|
| 86 | + * @since 12.0.0 |
|
| 87 | + */ |
|
| 88 | + public function activate(); |
|
| 89 | 89 | } |
@@ -30,38 +30,38 @@ |
||
| 30 | 30 | * @since 8.0.0 |
| 31 | 31 | */ |
| 32 | 32 | interface IQuery { |
| 33 | - /** |
|
| 34 | - * @return string |
|
| 35 | - * @since 8.0.0 |
|
| 36 | - */ |
|
| 37 | - public function getSql(); |
|
| 33 | + /** |
|
| 34 | + * @return string |
|
| 35 | + * @since 8.0.0 |
|
| 36 | + */ |
|
| 37 | + public function getSql(); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * @return array |
|
| 41 | - * @since 8.0.0 |
|
| 42 | - */ |
|
| 43 | - public function getParams(); |
|
| 39 | + /** |
|
| 40 | + * @return array |
|
| 41 | + * @since 8.0.0 |
|
| 42 | + */ |
|
| 43 | + public function getParams(); |
|
| 44 | 44 | |
| 45 | - /** |
|
| 46 | - * @return float |
|
| 47 | - * @since 8.0.0 |
|
| 48 | - */ |
|
| 49 | - public function getDuration(); |
|
| 45 | + /** |
|
| 46 | + * @return float |
|
| 47 | + * @since 8.0.0 |
|
| 48 | + */ |
|
| 49 | + public function getDuration(); |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @return float |
|
| 53 | - * @since 11.0.0 |
|
| 54 | - */ |
|
| 55 | - public function getStartTime(); |
|
| 51 | + /** |
|
| 52 | + * @return float |
|
| 53 | + * @since 11.0.0 |
|
| 54 | + */ |
|
| 55 | + public function getStartTime(); |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return array |
|
| 59 | - * @since 11.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getStacktrace(); |
|
| 62 | - /** |
|
| 63 | - * @return array |
|
| 64 | - * @since 12.0.0 |
|
| 65 | - */ |
|
| 66 | - public function getStart(); |
|
| 57 | + /** |
|
| 58 | + * @return array |
|
| 59 | + * @since 11.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getStacktrace(); |
|
| 62 | + /** |
|
| 63 | + * @return array |
|
| 64 | + * @since 12.0.0 |
|
| 65 | + */ |
|
| 66 | + public function getStart(); |
|
| 67 | 67 | } |
@@ -37,43 +37,43 @@ |
||
| 37 | 37 | * @since 8.0.0 |
| 38 | 38 | */ |
| 39 | 39 | interface IQueryLogger extends SQLLogger { |
| 40 | - /** |
|
| 41 | - * Mark the start of a query providing query SQL statement, its parameters and types. |
|
| 42 | - * This method should be called as close to the DB as possible and after |
|
| 43 | - * query is finished finalized with stopQuery() method. |
|
| 44 | - * |
|
| 45 | - * @param string $sql |
|
| 46 | - * @param array $params |
|
| 47 | - * @param array $types |
|
| 48 | - * @since 8.0.0 |
|
| 49 | - */ |
|
| 50 | - public function startQuery($sql, array $params = null, array $types = null); |
|
| 40 | + /** |
|
| 41 | + * Mark the start of a query providing query SQL statement, its parameters and types. |
|
| 42 | + * This method should be called as close to the DB as possible and after |
|
| 43 | + * query is finished finalized with stopQuery() method. |
|
| 44 | + * |
|
| 45 | + * @param string $sql |
|
| 46 | + * @param array $params |
|
| 47 | + * @param array $types |
|
| 48 | + * @since 8.0.0 |
|
| 49 | + */ |
|
| 50 | + public function startQuery($sql, array $params = null, array $types = null); |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to |
|
| 54 | - * be returned with getQueries() method. |
|
| 55 | - * |
|
| 56 | - * @return mixed |
|
| 57 | - * @since 8.0.0 |
|
| 58 | - */ |
|
| 59 | - public function stopQuery(); |
|
| 52 | + /** |
|
| 53 | + * Mark the end of the current active query. Ending query should store \OCP\Diagnostics\IQuery to |
|
| 54 | + * be returned with getQueries() method. |
|
| 55 | + * |
|
| 56 | + * @return mixed |
|
| 57 | + * @since 8.0.0 |
|
| 58 | + */ |
|
| 59 | + public function stopQuery(); |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * This method should return all \OCP\Diagnostics\IQuery objects stored using |
|
| 63 | - * startQuery()/stopQuery() methods. |
|
| 64 | - * |
|
| 65 | - * @return \OCP\Diagnostics\IQuery[] |
|
| 66 | - * @since 8.0.0 |
|
| 67 | - */ |
|
| 68 | - public function getQueries(); |
|
| 61 | + /** |
|
| 62 | + * This method should return all \OCP\Diagnostics\IQuery objects stored using |
|
| 63 | + * startQuery()/stopQuery() methods. |
|
| 64 | + * |
|
| 65 | + * @return \OCP\Diagnostics\IQuery[] |
|
| 66 | + * @since 8.0.0 |
|
| 67 | + */ |
|
| 68 | + public function getQueries(); |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Activate the module for the duration of the request. Deactivated module |
|
| 72 | - * does not create and store \OCP\Diagnostics\IQuery objects. |
|
| 73 | - * Only activated module should create and store objects to be |
|
| 74 | - * returned with getQueries() call. |
|
| 75 | - * |
|
| 76 | - * @since 12.0.0 |
|
| 77 | - */ |
|
| 78 | - public function activate(); |
|
| 70 | + /** |
|
| 71 | + * Activate the module for the duration of the request. Deactivated module |
|
| 72 | + * does not create and store \OCP\Diagnostics\IQuery objects. |
|
| 73 | + * Only activated module should create and store objects to be |
|
| 74 | + * returned with getQueries() call. |
|
| 75 | + * |
|
| 76 | + * @since 12.0.0 |
|
| 77 | + */ |
|
| 78 | + public function activate(); |
|
| 79 | 79 | } |
@@ -41,381 +41,381 @@ |
||
| 41 | 41 | use OCP\PreConditionNotMetException; |
| 42 | 42 | |
| 43 | 43 | class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { |
| 44 | - /** |
|
| 45 | - * @var string $tablePrefix |
|
| 46 | - */ |
|
| 47 | - protected $tablePrefix; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var \OC\DB\Adapter $adapter |
|
| 51 | - */ |
|
| 52 | - protected $adapter; |
|
| 53 | - |
|
| 54 | - protected $lockedTable = null; |
|
| 55 | - |
|
| 56 | - public function connect() { |
|
| 57 | - try { |
|
| 58 | - return parent::connect(); |
|
| 59 | - } catch (DBALException $e) { |
|
| 60 | - // throw a new exception to prevent leaking info from the stacktrace |
|
| 61 | - throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode()); |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Returns a QueryBuilder for the connection. |
|
| 67 | - * |
|
| 68 | - * @return \OCP\DB\QueryBuilder\IQueryBuilder |
|
| 69 | - */ |
|
| 70 | - public function getQueryBuilder() { |
|
| 71 | - return new QueryBuilder( |
|
| 72 | - $this, |
|
| 73 | - \OC::$server->getSystemConfig(), |
|
| 74 | - \OC::$server->getLogger() |
|
| 75 | - ); |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Gets the QueryBuilder for the connection. |
|
| 80 | - * |
|
| 81 | - * @return \Doctrine\DBAL\Query\QueryBuilder |
|
| 82 | - * @deprecated please use $this->getQueryBuilder() instead |
|
| 83 | - */ |
|
| 84 | - public function createQueryBuilder() { |
|
| 85 | - $backtrace = $this->getCallerBacktrace(); |
|
| 86 | - \OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); |
|
| 87 | - return parent::createQueryBuilder(); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Gets the ExpressionBuilder for the connection. |
|
| 92 | - * |
|
| 93 | - * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder |
|
| 94 | - * @deprecated please use $this->getQueryBuilder()->expr() instead |
|
| 95 | - */ |
|
| 96 | - public function getExpressionBuilder() { |
|
| 97 | - $backtrace = $this->getCallerBacktrace(); |
|
| 98 | - \OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); |
|
| 99 | - return parent::getExpressionBuilder(); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * Get the file and line that called the method where `getCallerBacktrace()` was used |
|
| 104 | - * |
|
| 105 | - * @return string |
|
| 106 | - */ |
|
| 107 | - protected function getCallerBacktrace() { |
|
| 108 | - $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
|
| 109 | - |
|
| 110 | - // 0 is the method where we use `getCallerBacktrace` |
|
| 111 | - // 1 is the target method which uses the method we want to log |
|
| 112 | - if (isset($traces[1])) { |
|
| 113 | - return $traces[1]['file'] . ':' . $traces[1]['line']; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - return ''; |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * @return string |
|
| 121 | - */ |
|
| 122 | - public function getPrefix() { |
|
| 123 | - return $this->tablePrefix; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - /** |
|
| 127 | - * Initializes a new instance of the Connection class. |
|
| 128 | - * |
|
| 129 | - * @param array $params The connection parameters. |
|
| 130 | - * @param \Doctrine\DBAL\Driver $driver |
|
| 131 | - * @param \Doctrine\DBAL\Configuration $config |
|
| 132 | - * @param \Doctrine\Common\EventManager $eventManager |
|
| 133 | - * @throws \Exception |
|
| 134 | - */ |
|
| 135 | - public function __construct(array $params, Driver $driver, Configuration $config = null, |
|
| 136 | - EventManager $eventManager = null) |
|
| 137 | - { |
|
| 138 | - if (!isset($params['adapter'])) { |
|
| 139 | - throw new \Exception('adapter not set'); |
|
| 140 | - } |
|
| 141 | - if (!isset($params['tablePrefix'])) { |
|
| 142 | - throw new \Exception('tablePrefix not set'); |
|
| 143 | - } |
|
| 144 | - parent::__construct($params, $driver, $config, $eventManager); |
|
| 145 | - $this->adapter = new $params['adapter']($this); |
|
| 146 | - $this->tablePrefix = $params['tablePrefix']; |
|
| 147 | - |
|
| 148 | - parent::setTransactionIsolation(parent::TRANSACTION_READ_COMMITTED); |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Prepares an SQL statement. |
|
| 153 | - * |
|
| 154 | - * @param string $statement The SQL statement to prepare. |
|
| 155 | - * @param int $limit |
|
| 156 | - * @param int $offset |
|
| 157 | - * @return \Doctrine\DBAL\Driver\Statement The prepared statement. |
|
| 158 | - */ |
|
| 159 | - public function prepare( $statement, $limit=null, $offset=null ) { |
|
| 160 | - if ($limit === -1) { |
|
| 161 | - $limit = null; |
|
| 162 | - } |
|
| 163 | - if (!is_null($limit)) { |
|
| 164 | - $platform = $this->getDatabasePlatform(); |
|
| 165 | - $statement = $platform->modifyLimitQuery($statement, $limit, $offset); |
|
| 166 | - } |
|
| 167 | - $statement = $this->replaceTablePrefix($statement); |
|
| 168 | - $statement = $this->adapter->fixupStatement($statement); |
|
| 169 | - |
|
| 170 | - return parent::prepare($statement); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Executes an, optionally parametrized, SQL query. |
|
| 175 | - * |
|
| 176 | - * If the query is parametrized, a prepared statement is used. |
|
| 177 | - * If an SQLLogger is configured, the execution is logged. |
|
| 178 | - * |
|
| 179 | - * @param string $query The SQL query to execute. |
|
| 180 | - * @param array $params The parameters to bind to the query, if any. |
|
| 181 | - * @param array $types The types the previous parameters are in. |
|
| 182 | - * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp The query cache profile, optional. |
|
| 183 | - * |
|
| 184 | - * @return \Doctrine\DBAL\Driver\Statement The executed statement. |
|
| 185 | - * |
|
| 186 | - * @throws \Doctrine\DBAL\DBALException |
|
| 187 | - */ |
|
| 188 | - public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null) |
|
| 189 | - { |
|
| 190 | - $query = $this->replaceTablePrefix($query); |
|
| 191 | - $query = $this->adapter->fixupStatement($query); |
|
| 192 | - return parent::executeQuery($query, $params, $types, $qcp); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters |
|
| 197 | - * and returns the number of affected rows. |
|
| 198 | - * |
|
| 199 | - * This method supports PDO binding types as well as DBAL mapping types. |
|
| 200 | - * |
|
| 201 | - * @param string $query The SQL query. |
|
| 202 | - * @param array $params The query parameters. |
|
| 203 | - * @param array $types The parameter types. |
|
| 204 | - * |
|
| 205 | - * @return integer The number of affected rows. |
|
| 206 | - * |
|
| 207 | - * @throws \Doctrine\DBAL\DBALException |
|
| 208 | - */ |
|
| 209 | - public function executeUpdate($query, array $params = array(), array $types = array()) |
|
| 210 | - { |
|
| 211 | - $query = $this->replaceTablePrefix($query); |
|
| 212 | - $query = $this->adapter->fixupStatement($query); |
|
| 213 | - return parent::executeUpdate($query, $params, $types); |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Returns the ID of the last inserted row, or the last value from a sequence object, |
|
| 218 | - * depending on the underlying driver. |
|
| 219 | - * |
|
| 220 | - * Note: This method may not return a meaningful or consistent result across different drivers, |
|
| 221 | - * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY |
|
| 222 | - * columns or sequences. |
|
| 223 | - * |
|
| 224 | - * @param string $seqName Name of the sequence object from which the ID should be returned. |
|
| 225 | - * @return string A string representation of the last inserted ID. |
|
| 226 | - */ |
|
| 227 | - public function lastInsertId($seqName = null) { |
|
| 228 | - if ($seqName) { |
|
| 229 | - $seqName = $this->replaceTablePrefix($seqName); |
|
| 230 | - } |
|
| 231 | - return $this->adapter->lastInsertId($seqName); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - // internal use |
|
| 235 | - public function realLastInsertId($seqName = null) { |
|
| 236 | - return parent::lastInsertId($seqName); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * Insert a row if the matching row does not exists. |
|
| 241 | - * |
|
| 242 | - * @param string $table The table name (will replace *PREFIX* with the actual prefix) |
|
| 243 | - * @param array $input data that should be inserted into the table (column name => value) |
|
| 244 | - * @param array|null $compare List of values that should be checked for "if not exists" |
|
| 245 | - * If this is null or an empty array, all keys of $input will be compared |
|
| 246 | - * Please note: text fields (clob) must not be used in the compare array |
|
| 247 | - * @return int number of inserted rows |
|
| 248 | - * @throws \Doctrine\DBAL\DBALException |
|
| 249 | - */ |
|
| 250 | - public function insertIfNotExist($table, $input, array $compare = null) { |
|
| 251 | - return $this->adapter->insertIfNotExist($table, $input, $compare); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - private function getType($value) { |
|
| 255 | - if (is_bool($value)) { |
|
| 256 | - return IQueryBuilder::PARAM_BOOL; |
|
| 257 | - } else if (is_int($value)) { |
|
| 258 | - return IQueryBuilder::PARAM_INT; |
|
| 259 | - } else { |
|
| 260 | - return IQueryBuilder::PARAM_STR; |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * Insert or update a row value |
|
| 266 | - * |
|
| 267 | - * @param string $table |
|
| 268 | - * @param array $keys (column name => value) |
|
| 269 | - * @param array $values (column name => value) |
|
| 270 | - * @param array $updatePreconditionValues ensure values match preconditions (column name => value) |
|
| 271 | - * @return int number of new rows |
|
| 272 | - * @throws \Doctrine\DBAL\DBALException |
|
| 273 | - * @throws PreConditionNotMetException |
|
| 274 | - */ |
|
| 275 | - public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []) { |
|
| 276 | - try { |
|
| 277 | - $insertQb = $this->getQueryBuilder(); |
|
| 278 | - $insertQb->insert($table) |
|
| 279 | - ->values( |
|
| 280 | - array_map(function($value) use ($insertQb) { |
|
| 281 | - return $insertQb->createNamedParameter($value, $this->getType($value)); |
|
| 282 | - }, array_merge($keys, $values)) |
|
| 283 | - ); |
|
| 284 | - return $insertQb->execute(); |
|
| 285 | - } catch (ConstraintViolationException $e) { |
|
| 286 | - // value already exists, try update |
|
| 287 | - $updateQb = $this->getQueryBuilder(); |
|
| 288 | - $updateQb->update($table); |
|
| 289 | - foreach ($values as $name => $value) { |
|
| 290 | - $updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value))); |
|
| 291 | - } |
|
| 292 | - $where = $updateQb->expr()->andX(); |
|
| 293 | - $whereValues = array_merge($keys, $updatePreconditionValues); |
|
| 294 | - foreach ($whereValues as $name => $value) { |
|
| 295 | - $where->add($updateQb->expr()->eq( |
|
| 296 | - $name, |
|
| 297 | - $updateQb->createNamedParameter($value, $this->getType($value)), |
|
| 298 | - $this->getType($value) |
|
| 299 | - )); |
|
| 300 | - } |
|
| 301 | - $updateQb->where($where); |
|
| 302 | - $affected = $updateQb->execute(); |
|
| 303 | - |
|
| 304 | - if ($affected === 0 && !empty($updatePreconditionValues)) { |
|
| 305 | - throw new PreConditionNotMetException(); |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - return 0; |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - /** |
|
| 313 | - * Create an exclusive read+write lock on a table |
|
| 314 | - * |
|
| 315 | - * @param string $tableName |
|
| 316 | - * @throws \BadMethodCallException When trying to acquire a second lock |
|
| 317 | - * @since 9.1.0 |
|
| 318 | - */ |
|
| 319 | - public function lockTable($tableName) { |
|
| 320 | - if ($this->lockedTable !== null) { |
|
| 321 | - throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.'); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - $tableName = $this->tablePrefix . $tableName; |
|
| 325 | - $this->lockedTable = $tableName; |
|
| 326 | - $this->adapter->lockTable($tableName); |
|
| 327 | - } |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * Release a previous acquired lock again |
|
| 331 | - * |
|
| 332 | - * @since 9.1.0 |
|
| 333 | - */ |
|
| 334 | - public function unlockTable() { |
|
| 335 | - $this->adapter->unlockTable(); |
|
| 336 | - $this->lockedTable = null; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * returns the error code and message as a string for logging |
|
| 341 | - * works with DoctrineException |
|
| 342 | - * @return string |
|
| 343 | - */ |
|
| 344 | - public function getError() { |
|
| 345 | - $msg = $this->errorCode() . ': '; |
|
| 346 | - $errorInfo = $this->errorInfo(); |
|
| 347 | - if (is_array($errorInfo)) { |
|
| 348 | - $msg .= 'SQLSTATE = '.$errorInfo[0] . ', '; |
|
| 349 | - $msg .= 'Driver Code = '.$errorInfo[1] . ', '; |
|
| 350 | - $msg .= 'Driver Message = '.$errorInfo[2]; |
|
| 351 | - } |
|
| 352 | - return $msg; |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - /** |
|
| 356 | - * Drop a table from the database if it exists |
|
| 357 | - * |
|
| 358 | - * @param string $table table name without the prefix |
|
| 359 | - */ |
|
| 360 | - public function dropTable($table) { |
|
| 361 | - $table = $this->tablePrefix . trim($table); |
|
| 362 | - $schema = $this->getSchemaManager(); |
|
| 363 | - if($schema->tablesExist(array($table))) { |
|
| 364 | - $schema->dropTable($table); |
|
| 365 | - } |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - /** |
|
| 369 | - * Check if a table exists |
|
| 370 | - * |
|
| 371 | - * @param string $table table name without the prefix |
|
| 372 | - * @return bool |
|
| 373 | - */ |
|
| 374 | - public function tableExists($table){ |
|
| 375 | - $table = $this->tablePrefix . trim($table); |
|
| 376 | - $schema = $this->getSchemaManager(); |
|
| 377 | - return $schema->tablesExist(array($table)); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - // internal use |
|
| 381 | - /** |
|
| 382 | - * @param string $statement |
|
| 383 | - * @return string |
|
| 384 | - */ |
|
| 385 | - protected function replaceTablePrefix($statement) { |
|
| 386 | - return str_replace( '*PREFIX*', $this->tablePrefix, $statement ); |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * Check if a transaction is active |
|
| 391 | - * |
|
| 392 | - * @return bool |
|
| 393 | - * @since 8.2.0 |
|
| 394 | - */ |
|
| 395 | - public function inTransaction() { |
|
| 396 | - return $this->getTransactionNestingLevel() > 0; |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - /** |
|
| 400 | - * Espace a parameter to be used in a LIKE query |
|
| 401 | - * |
|
| 402 | - * @param string $param |
|
| 403 | - * @return string |
|
| 404 | - */ |
|
| 405 | - public function escapeLikeParameter($param) { |
|
| 406 | - return addcslashes($param, '\\_%'); |
|
| 407 | - } |
|
| 408 | - |
|
| 409 | - /** |
|
| 410 | - * Check whether or not the current database support 4byte wide unicode |
|
| 411 | - * |
|
| 412 | - * @return bool |
|
| 413 | - * @since 11.0.0 |
|
| 414 | - */ |
|
| 415 | - public function supports4ByteText() { |
|
| 416 | - if (!$this->getDatabasePlatform() instanceof MySqlPlatform) { |
|
| 417 | - return true; |
|
| 418 | - } |
|
| 419 | - return $this->getParams()['charset'] === 'utf8mb4'; |
|
| 420 | - } |
|
| 44 | + /** |
|
| 45 | + * @var string $tablePrefix |
|
| 46 | + */ |
|
| 47 | + protected $tablePrefix; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var \OC\DB\Adapter $adapter |
|
| 51 | + */ |
|
| 52 | + protected $adapter; |
|
| 53 | + |
|
| 54 | + protected $lockedTable = null; |
|
| 55 | + |
|
| 56 | + public function connect() { |
|
| 57 | + try { |
|
| 58 | + return parent::connect(); |
|
| 59 | + } catch (DBALException $e) { |
|
| 60 | + // throw a new exception to prevent leaking info from the stacktrace |
|
| 61 | + throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode()); |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Returns a QueryBuilder for the connection. |
|
| 67 | + * |
|
| 68 | + * @return \OCP\DB\QueryBuilder\IQueryBuilder |
|
| 69 | + */ |
|
| 70 | + public function getQueryBuilder() { |
|
| 71 | + return new QueryBuilder( |
|
| 72 | + $this, |
|
| 73 | + \OC::$server->getSystemConfig(), |
|
| 74 | + \OC::$server->getLogger() |
|
| 75 | + ); |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Gets the QueryBuilder for the connection. |
|
| 80 | + * |
|
| 81 | + * @return \Doctrine\DBAL\Query\QueryBuilder |
|
| 82 | + * @deprecated please use $this->getQueryBuilder() instead |
|
| 83 | + */ |
|
| 84 | + public function createQueryBuilder() { |
|
| 85 | + $backtrace = $this->getCallerBacktrace(); |
|
| 86 | + \OC::$server->getLogger()->debug('Doctrine QueryBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); |
|
| 87 | + return parent::createQueryBuilder(); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Gets the ExpressionBuilder for the connection. |
|
| 92 | + * |
|
| 93 | + * @return \Doctrine\DBAL\Query\Expression\ExpressionBuilder |
|
| 94 | + * @deprecated please use $this->getQueryBuilder()->expr() instead |
|
| 95 | + */ |
|
| 96 | + public function getExpressionBuilder() { |
|
| 97 | + $backtrace = $this->getCallerBacktrace(); |
|
| 98 | + \OC::$server->getLogger()->debug('Doctrine ExpressionBuilder retrieved in {backtrace}', ['app' => 'core', 'backtrace' => $backtrace]); |
|
| 99 | + return parent::getExpressionBuilder(); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * Get the file and line that called the method where `getCallerBacktrace()` was used |
|
| 104 | + * |
|
| 105 | + * @return string |
|
| 106 | + */ |
|
| 107 | + protected function getCallerBacktrace() { |
|
| 108 | + $traces = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2); |
|
| 109 | + |
|
| 110 | + // 0 is the method where we use `getCallerBacktrace` |
|
| 111 | + // 1 is the target method which uses the method we want to log |
|
| 112 | + if (isset($traces[1])) { |
|
| 113 | + return $traces[1]['file'] . ':' . $traces[1]['line']; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + return ''; |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * @return string |
|
| 121 | + */ |
|
| 122 | + public function getPrefix() { |
|
| 123 | + return $this->tablePrefix; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + /** |
|
| 127 | + * Initializes a new instance of the Connection class. |
|
| 128 | + * |
|
| 129 | + * @param array $params The connection parameters. |
|
| 130 | + * @param \Doctrine\DBAL\Driver $driver |
|
| 131 | + * @param \Doctrine\DBAL\Configuration $config |
|
| 132 | + * @param \Doctrine\Common\EventManager $eventManager |
|
| 133 | + * @throws \Exception |
|
| 134 | + */ |
|
| 135 | + public function __construct(array $params, Driver $driver, Configuration $config = null, |
|
| 136 | + EventManager $eventManager = null) |
|
| 137 | + { |
|
| 138 | + if (!isset($params['adapter'])) { |
|
| 139 | + throw new \Exception('adapter not set'); |
|
| 140 | + } |
|
| 141 | + if (!isset($params['tablePrefix'])) { |
|
| 142 | + throw new \Exception('tablePrefix not set'); |
|
| 143 | + } |
|
| 144 | + parent::__construct($params, $driver, $config, $eventManager); |
|
| 145 | + $this->adapter = new $params['adapter']($this); |
|
| 146 | + $this->tablePrefix = $params['tablePrefix']; |
|
| 147 | + |
|
| 148 | + parent::setTransactionIsolation(parent::TRANSACTION_READ_COMMITTED); |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Prepares an SQL statement. |
|
| 153 | + * |
|
| 154 | + * @param string $statement The SQL statement to prepare. |
|
| 155 | + * @param int $limit |
|
| 156 | + * @param int $offset |
|
| 157 | + * @return \Doctrine\DBAL\Driver\Statement The prepared statement. |
|
| 158 | + */ |
|
| 159 | + public function prepare( $statement, $limit=null, $offset=null ) { |
|
| 160 | + if ($limit === -1) { |
|
| 161 | + $limit = null; |
|
| 162 | + } |
|
| 163 | + if (!is_null($limit)) { |
|
| 164 | + $platform = $this->getDatabasePlatform(); |
|
| 165 | + $statement = $platform->modifyLimitQuery($statement, $limit, $offset); |
|
| 166 | + } |
|
| 167 | + $statement = $this->replaceTablePrefix($statement); |
|
| 168 | + $statement = $this->adapter->fixupStatement($statement); |
|
| 169 | + |
|
| 170 | + return parent::prepare($statement); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Executes an, optionally parametrized, SQL query. |
|
| 175 | + * |
|
| 176 | + * If the query is parametrized, a prepared statement is used. |
|
| 177 | + * If an SQLLogger is configured, the execution is logged. |
|
| 178 | + * |
|
| 179 | + * @param string $query The SQL query to execute. |
|
| 180 | + * @param array $params The parameters to bind to the query, if any. |
|
| 181 | + * @param array $types The types the previous parameters are in. |
|
| 182 | + * @param \Doctrine\DBAL\Cache\QueryCacheProfile|null $qcp The query cache profile, optional. |
|
| 183 | + * |
|
| 184 | + * @return \Doctrine\DBAL\Driver\Statement The executed statement. |
|
| 185 | + * |
|
| 186 | + * @throws \Doctrine\DBAL\DBALException |
|
| 187 | + */ |
|
| 188 | + public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null) |
|
| 189 | + { |
|
| 190 | + $query = $this->replaceTablePrefix($query); |
|
| 191 | + $query = $this->adapter->fixupStatement($query); |
|
| 192 | + return parent::executeQuery($query, $params, $types, $qcp); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Executes an SQL INSERT/UPDATE/DELETE query with the given parameters |
|
| 197 | + * and returns the number of affected rows. |
|
| 198 | + * |
|
| 199 | + * This method supports PDO binding types as well as DBAL mapping types. |
|
| 200 | + * |
|
| 201 | + * @param string $query The SQL query. |
|
| 202 | + * @param array $params The query parameters. |
|
| 203 | + * @param array $types The parameter types. |
|
| 204 | + * |
|
| 205 | + * @return integer The number of affected rows. |
|
| 206 | + * |
|
| 207 | + * @throws \Doctrine\DBAL\DBALException |
|
| 208 | + */ |
|
| 209 | + public function executeUpdate($query, array $params = array(), array $types = array()) |
|
| 210 | + { |
|
| 211 | + $query = $this->replaceTablePrefix($query); |
|
| 212 | + $query = $this->adapter->fixupStatement($query); |
|
| 213 | + return parent::executeUpdate($query, $params, $types); |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Returns the ID of the last inserted row, or the last value from a sequence object, |
|
| 218 | + * depending on the underlying driver. |
|
| 219 | + * |
|
| 220 | + * Note: This method may not return a meaningful or consistent result across different drivers, |
|
| 221 | + * because the underlying database may not even support the notion of AUTO_INCREMENT/IDENTITY |
|
| 222 | + * columns or sequences. |
|
| 223 | + * |
|
| 224 | + * @param string $seqName Name of the sequence object from which the ID should be returned. |
|
| 225 | + * @return string A string representation of the last inserted ID. |
|
| 226 | + */ |
|
| 227 | + public function lastInsertId($seqName = null) { |
|
| 228 | + if ($seqName) { |
|
| 229 | + $seqName = $this->replaceTablePrefix($seqName); |
|
| 230 | + } |
|
| 231 | + return $this->adapter->lastInsertId($seqName); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + // internal use |
|
| 235 | + public function realLastInsertId($seqName = null) { |
|
| 236 | + return parent::lastInsertId($seqName); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * Insert a row if the matching row does not exists. |
|
| 241 | + * |
|
| 242 | + * @param string $table The table name (will replace *PREFIX* with the actual prefix) |
|
| 243 | + * @param array $input data that should be inserted into the table (column name => value) |
|
| 244 | + * @param array|null $compare List of values that should be checked for "if not exists" |
|
| 245 | + * If this is null or an empty array, all keys of $input will be compared |
|
| 246 | + * Please note: text fields (clob) must not be used in the compare array |
|
| 247 | + * @return int number of inserted rows |
|
| 248 | + * @throws \Doctrine\DBAL\DBALException |
|
| 249 | + */ |
|
| 250 | + public function insertIfNotExist($table, $input, array $compare = null) { |
|
| 251 | + return $this->adapter->insertIfNotExist($table, $input, $compare); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + private function getType($value) { |
|
| 255 | + if (is_bool($value)) { |
|
| 256 | + return IQueryBuilder::PARAM_BOOL; |
|
| 257 | + } else if (is_int($value)) { |
|
| 258 | + return IQueryBuilder::PARAM_INT; |
|
| 259 | + } else { |
|
| 260 | + return IQueryBuilder::PARAM_STR; |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * Insert or update a row value |
|
| 266 | + * |
|
| 267 | + * @param string $table |
|
| 268 | + * @param array $keys (column name => value) |
|
| 269 | + * @param array $values (column name => value) |
|
| 270 | + * @param array $updatePreconditionValues ensure values match preconditions (column name => value) |
|
| 271 | + * @return int number of new rows |
|
| 272 | + * @throws \Doctrine\DBAL\DBALException |
|
| 273 | + * @throws PreConditionNotMetException |
|
| 274 | + */ |
|
| 275 | + public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []) { |
|
| 276 | + try { |
|
| 277 | + $insertQb = $this->getQueryBuilder(); |
|
| 278 | + $insertQb->insert($table) |
|
| 279 | + ->values( |
|
| 280 | + array_map(function($value) use ($insertQb) { |
|
| 281 | + return $insertQb->createNamedParameter($value, $this->getType($value)); |
|
| 282 | + }, array_merge($keys, $values)) |
|
| 283 | + ); |
|
| 284 | + return $insertQb->execute(); |
|
| 285 | + } catch (ConstraintViolationException $e) { |
|
| 286 | + // value already exists, try update |
|
| 287 | + $updateQb = $this->getQueryBuilder(); |
|
| 288 | + $updateQb->update($table); |
|
| 289 | + foreach ($values as $name => $value) { |
|
| 290 | + $updateQb->set($name, $updateQb->createNamedParameter($value, $this->getType($value))); |
|
| 291 | + } |
|
| 292 | + $where = $updateQb->expr()->andX(); |
|
| 293 | + $whereValues = array_merge($keys, $updatePreconditionValues); |
|
| 294 | + foreach ($whereValues as $name => $value) { |
|
| 295 | + $where->add($updateQb->expr()->eq( |
|
| 296 | + $name, |
|
| 297 | + $updateQb->createNamedParameter($value, $this->getType($value)), |
|
| 298 | + $this->getType($value) |
|
| 299 | + )); |
|
| 300 | + } |
|
| 301 | + $updateQb->where($where); |
|
| 302 | + $affected = $updateQb->execute(); |
|
| 303 | + |
|
| 304 | + if ($affected === 0 && !empty($updatePreconditionValues)) { |
|
| 305 | + throw new PreConditionNotMetException(); |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + return 0; |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + /** |
|
| 313 | + * Create an exclusive read+write lock on a table |
|
| 314 | + * |
|
| 315 | + * @param string $tableName |
|
| 316 | + * @throws \BadMethodCallException When trying to acquire a second lock |
|
| 317 | + * @since 9.1.0 |
|
| 318 | + */ |
|
| 319 | + public function lockTable($tableName) { |
|
| 320 | + if ($this->lockedTable !== null) { |
|
| 321 | + throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.'); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + $tableName = $this->tablePrefix . $tableName; |
|
| 325 | + $this->lockedTable = $tableName; |
|
| 326 | + $this->adapter->lockTable($tableName); |
|
| 327 | + } |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * Release a previous acquired lock again |
|
| 331 | + * |
|
| 332 | + * @since 9.1.0 |
|
| 333 | + */ |
|
| 334 | + public function unlockTable() { |
|
| 335 | + $this->adapter->unlockTable(); |
|
| 336 | + $this->lockedTable = null; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * returns the error code and message as a string for logging |
|
| 341 | + * works with DoctrineException |
|
| 342 | + * @return string |
|
| 343 | + */ |
|
| 344 | + public function getError() { |
|
| 345 | + $msg = $this->errorCode() . ': '; |
|
| 346 | + $errorInfo = $this->errorInfo(); |
|
| 347 | + if (is_array($errorInfo)) { |
|
| 348 | + $msg .= 'SQLSTATE = '.$errorInfo[0] . ', '; |
|
| 349 | + $msg .= 'Driver Code = '.$errorInfo[1] . ', '; |
|
| 350 | + $msg .= 'Driver Message = '.$errorInfo[2]; |
|
| 351 | + } |
|
| 352 | + return $msg; |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + /** |
|
| 356 | + * Drop a table from the database if it exists |
|
| 357 | + * |
|
| 358 | + * @param string $table table name without the prefix |
|
| 359 | + */ |
|
| 360 | + public function dropTable($table) { |
|
| 361 | + $table = $this->tablePrefix . trim($table); |
|
| 362 | + $schema = $this->getSchemaManager(); |
|
| 363 | + if($schema->tablesExist(array($table))) { |
|
| 364 | + $schema->dropTable($table); |
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + /** |
|
| 369 | + * Check if a table exists |
|
| 370 | + * |
|
| 371 | + * @param string $table table name without the prefix |
|
| 372 | + * @return bool |
|
| 373 | + */ |
|
| 374 | + public function tableExists($table){ |
|
| 375 | + $table = $this->tablePrefix . trim($table); |
|
| 376 | + $schema = $this->getSchemaManager(); |
|
| 377 | + return $schema->tablesExist(array($table)); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + // internal use |
|
| 381 | + /** |
|
| 382 | + * @param string $statement |
|
| 383 | + * @return string |
|
| 384 | + */ |
|
| 385 | + protected function replaceTablePrefix($statement) { |
|
| 386 | + return str_replace( '*PREFIX*', $this->tablePrefix, $statement ); |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * Check if a transaction is active |
|
| 391 | + * |
|
| 392 | + * @return bool |
|
| 393 | + * @since 8.2.0 |
|
| 394 | + */ |
|
| 395 | + public function inTransaction() { |
|
| 396 | + return $this->getTransactionNestingLevel() > 0; |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + /** |
|
| 400 | + * Espace a parameter to be used in a LIKE query |
|
| 401 | + * |
|
| 402 | + * @param string $param |
|
| 403 | + * @return string |
|
| 404 | + */ |
|
| 405 | + public function escapeLikeParameter($param) { |
|
| 406 | + return addcslashes($param, '\\_%'); |
|
| 407 | + } |
|
| 408 | + |
|
| 409 | + /** |
|
| 410 | + * Check whether or not the current database support 4byte wide unicode |
|
| 411 | + * |
|
| 412 | + * @return bool |
|
| 413 | + * @since 11.0.0 |
|
| 414 | + */ |
|
| 415 | + public function supports4ByteText() { |
|
| 416 | + if (!$this->getDatabasePlatform() instanceof MySqlPlatform) { |
|
| 417 | + return true; |
|
| 418 | + } |
|
| 419 | + return $this->getParams()['charset'] === 'utf8mb4'; |
|
| 420 | + } |
|
| 421 | 421 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | return parent::connect(); |
| 59 | 59 | } catch (DBALException $e) { |
| 60 | 60 | // throw a new exception to prevent leaking info from the stacktrace |
| 61 | - throw new DBALException('Failed to connect to the database: ' . $e->getMessage(), $e->getCode()); |
|
| 61 | + throw new DBALException('Failed to connect to the database: '.$e->getMessage(), $e->getCode()); |
|
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | // 0 is the method where we use `getCallerBacktrace` |
| 111 | 111 | // 1 is the target method which uses the method we want to log |
| 112 | 112 | if (isset($traces[1])) { |
| 113 | - return $traces[1]['file'] . ':' . $traces[1]['line']; |
|
| 113 | + return $traces[1]['file'].':'.$traces[1]['line']; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | return ''; |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param int $offset |
| 157 | 157 | * @return \Doctrine\DBAL\Driver\Statement The prepared statement. |
| 158 | 158 | */ |
| 159 | - public function prepare( $statement, $limit=null, $offset=null ) { |
|
| 159 | + public function prepare($statement, $limit = null, $offset = null) { |
|
| 160 | 160 | if ($limit === -1) { |
| 161 | 161 | $limit = null; |
| 162 | 162 | } |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | throw new \BadMethodCallException('Can not lock a new table until the previous lock is released.'); |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | - $tableName = $this->tablePrefix . $tableName; |
|
| 324 | + $tableName = $this->tablePrefix.$tableName; |
|
| 325 | 325 | $this->lockedTable = $tableName; |
| 326 | 326 | $this->adapter->lockTable($tableName); |
| 327 | 327 | } |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | * @return string |
| 343 | 343 | */ |
| 344 | 344 | public function getError() { |
| 345 | - $msg = $this->errorCode() . ': '; |
|
| 345 | + $msg = $this->errorCode().': '; |
|
| 346 | 346 | $errorInfo = $this->errorInfo(); |
| 347 | 347 | if (is_array($errorInfo)) { |
| 348 | - $msg .= 'SQLSTATE = '.$errorInfo[0] . ', '; |
|
| 349 | - $msg .= 'Driver Code = '.$errorInfo[1] . ', '; |
|
| 348 | + $msg .= 'SQLSTATE = '.$errorInfo[0].', '; |
|
| 349 | + $msg .= 'Driver Code = '.$errorInfo[1].', '; |
|
| 350 | 350 | $msg .= 'Driver Message = '.$errorInfo[2]; |
| 351 | 351 | } |
| 352 | 352 | return $msg; |
@@ -358,9 +358,9 @@ discard block |
||
| 358 | 358 | * @param string $table table name without the prefix |
| 359 | 359 | */ |
| 360 | 360 | public function dropTable($table) { |
| 361 | - $table = $this->tablePrefix . trim($table); |
|
| 361 | + $table = $this->tablePrefix.trim($table); |
|
| 362 | 362 | $schema = $this->getSchemaManager(); |
| 363 | - if($schema->tablesExist(array($table))) { |
|
| 363 | + if ($schema->tablesExist(array($table))) { |
|
| 364 | 364 | $schema->dropTable($table); |
| 365 | 365 | } |
| 366 | 366 | } |
@@ -371,8 +371,8 @@ discard block |
||
| 371 | 371 | * @param string $table table name without the prefix |
| 372 | 372 | * @return bool |
| 373 | 373 | */ |
| 374 | - public function tableExists($table){ |
|
| 375 | - $table = $this->tablePrefix . trim($table); |
|
| 374 | + public function tableExists($table) { |
|
| 375 | + $table = $this->tablePrefix.trim($table); |
|
| 376 | 376 | $schema = $this->getSchemaManager(); |
| 377 | 377 | return $schema->tablesExist(array($table)); |
| 378 | 378 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @return string |
| 384 | 384 | */ |
| 385 | 385 | protected function replaceTablePrefix($statement) { |
| 386 | - return str_replace( '*PREFIX*', $this->tablePrefix, $statement ); |
|
| 386 | + return str_replace('*PREFIX*', $this->tablePrefix, $statement); |
|
| 387 | 387 | } |
| 388 | 388 | |
| 389 | 389 | /** |
@@ -36,84 +36,84 @@ |
||
| 36 | 36 | * @method array fetchAll(integer $fetchMode = null); |
| 37 | 37 | */ |
| 38 | 38 | class OC_DB_StatementWrapper { |
| 39 | - /** |
|
| 40 | - * @var \Doctrine\DBAL\Driver\Statement |
|
| 41 | - */ |
|
| 42 | - private $statement = null; |
|
| 43 | - private $isManipulation = false; |
|
| 44 | - private $lastArguments = array(); |
|
| 39 | + /** |
|
| 40 | + * @var \Doctrine\DBAL\Driver\Statement |
|
| 41 | + */ |
|
| 42 | + private $statement = null; |
|
| 43 | + private $isManipulation = false; |
|
| 44 | + private $lastArguments = array(); |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @param boolean $isManipulation |
|
| 48 | - */ |
|
| 49 | - public function __construct($statement, $isManipulation) { |
|
| 50 | - $this->statement = $statement; |
|
| 51 | - $this->isManipulation = $isManipulation; |
|
| 52 | - } |
|
| 46 | + /** |
|
| 47 | + * @param boolean $isManipulation |
|
| 48 | + */ |
|
| 49 | + public function __construct($statement, $isManipulation) { |
|
| 50 | + $this->statement = $statement; |
|
| 51 | + $this->isManipulation = $isManipulation; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
|
| 56 | - */ |
|
| 57 | - public function __call($name,$arguments) { |
|
| 58 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
|
| 56 | + */ |
|
| 57 | + public function __call($name,$arguments) { |
|
| 58 | + return call_user_func_array(array($this->statement,$name), $arguments); |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * make execute return the result instead of a bool |
|
| 63 | - * |
|
| 64 | - * @param array $input |
|
| 65 | - * @return \OC_DB_StatementWrapper|int |
|
| 66 | - */ |
|
| 67 | - public function execute($input= []) { |
|
| 68 | - $this->lastArguments = $input; |
|
| 69 | - if (count($input) > 0) { |
|
| 70 | - $result = $this->statement->execute($input); |
|
| 71 | - } else { |
|
| 72 | - $result = $this->statement->execute(); |
|
| 73 | - } |
|
| 61 | + /** |
|
| 62 | + * make execute return the result instead of a bool |
|
| 63 | + * |
|
| 64 | + * @param array $input |
|
| 65 | + * @return \OC_DB_StatementWrapper|int |
|
| 66 | + */ |
|
| 67 | + public function execute($input= []) { |
|
| 68 | + $this->lastArguments = $input; |
|
| 69 | + if (count($input) > 0) { |
|
| 70 | + $result = $this->statement->execute($input); |
|
| 71 | + } else { |
|
| 72 | + $result = $this->statement->execute(); |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - if ($result === false) { |
|
| 76 | - return false; |
|
| 77 | - } |
|
| 78 | - if ($this->isManipulation) { |
|
| 79 | - $count = $this->statement->rowCount(); |
|
| 80 | - return $count; |
|
| 81 | - } else { |
|
| 82 | - return $this; |
|
| 83 | - } |
|
| 84 | - } |
|
| 75 | + if ($result === false) { |
|
| 76 | + return false; |
|
| 77 | + } |
|
| 78 | + if ($this->isManipulation) { |
|
| 79 | + $count = $this->statement->rowCount(); |
|
| 80 | + return $count; |
|
| 81 | + } else { |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * provide an alias for fetch |
|
| 88 | - * |
|
| 89 | - * @return mixed |
|
| 90 | - */ |
|
| 91 | - public function fetchRow() { |
|
| 92 | - return $this->statement->fetch(); |
|
| 93 | - } |
|
| 86 | + /** |
|
| 87 | + * provide an alias for fetch |
|
| 88 | + * |
|
| 89 | + * @return mixed |
|
| 90 | + */ |
|
| 91 | + public function fetchRow() { |
|
| 92 | + return $this->statement->fetch(); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * Provide a simple fetchOne. |
|
| 97 | - * |
|
| 98 | - * fetch single column from the next row |
|
| 99 | - * @param int $column the column number to fetch |
|
| 100 | - * @return string |
|
| 101 | - */ |
|
| 102 | - public function fetchOne($column = 0) { |
|
| 103 | - return $this->statement->fetchColumn($column); |
|
| 104 | - } |
|
| 95 | + /** |
|
| 96 | + * Provide a simple fetchOne. |
|
| 97 | + * |
|
| 98 | + * fetch single column from the next row |
|
| 99 | + * @param int $column the column number to fetch |
|
| 100 | + * @return string |
|
| 101 | + */ |
|
| 102 | + public function fetchOne($column = 0) { |
|
| 103 | + return $this->statement->fetchColumn($column); |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Binds a PHP variable to a corresponding named or question mark placeholder in the |
|
| 108 | - * SQL statement that was use to prepare the statement. |
|
| 109 | - * |
|
| 110 | - * @param mixed $column Either the placeholder name or the 1-indexed placeholder index |
|
| 111 | - * @param mixed $variable The variable to bind |
|
| 112 | - * @param integer|null $type one of the PDO::PARAM_* constants |
|
| 113 | - * @param integer|null $length max length when using an OUT bind |
|
| 114 | - * @return boolean |
|
| 115 | - */ |
|
| 116 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
| 117 | - return $this->statement->bindParam($column, $variable, $type, $length); |
|
| 118 | - } |
|
| 106 | + /** |
|
| 107 | + * Binds a PHP variable to a corresponding named or question mark placeholder in the |
|
| 108 | + * SQL statement that was use to prepare the statement. |
|
| 109 | + * |
|
| 110 | + * @param mixed $column Either the placeholder name or the 1-indexed placeholder index |
|
| 111 | + * @param mixed $variable The variable to bind |
|
| 112 | + * @param integer|null $type one of the PDO::PARAM_* constants |
|
| 113 | + * @param integer|null $length max length when using an OUT bind |
|
| 114 | + * @return boolean |
|
| 115 | + */ |
|
| 116 | + public function bindParam($column, &$variable, $type = null, $length = null){ |
|
| 117 | + return $this->statement->bindParam($column, $variable, $type, $length); |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -54,8 +54,8 @@ discard block |
||
| 54 | 54 | /** |
| 55 | 55 | * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
| 56 | 56 | */ |
| 57 | - public function __call($name,$arguments) { |
|
| 58 | - return call_user_func_array(array($this->statement,$name), $arguments); |
|
| 57 | + public function __call($name, $arguments) { |
|
| 58 | + return call_user_func_array(array($this->statement, $name), $arguments); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | * @param array $input |
| 65 | 65 | * @return \OC_DB_StatementWrapper|int |
| 66 | 66 | */ |
| 67 | - public function execute($input= []) { |
|
| 67 | + public function execute($input = []) { |
|
| 68 | 68 | $this->lastArguments = $input; |
| 69 | 69 | if (count($input) > 0) { |
| 70 | 70 | $result = $this->statement->execute($input); |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @param integer|null $length max length when using an OUT bind |
| 114 | 114 | * @return boolean |
| 115 | 115 | */ |
| 116 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
| 116 | + public function bindParam($column, &$variable, $type = null, $length = null) { |
|
| 117 | 117 | return $this->statement->bindParam($column, $variable, $type, $length); |
| 118 | 118 | } |
| 119 | 119 | } |
@@ -28,56 +28,56 @@ |
||
| 28 | 28 | use OCP\Diagnostics\IEventLogger; |
| 29 | 29 | |
| 30 | 30 | class EventLogger implements IEventLogger { |
| 31 | - /** |
|
| 32 | - * @var \OC\Diagnostics\Event[] |
|
| 33 | - */ |
|
| 34 | - private $events = []; |
|
| 31 | + /** |
|
| 32 | + * @var \OC\Diagnostics\Event[] |
|
| 33 | + */ |
|
| 34 | + private $events = []; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var bool - Module needs to be activated by some app |
|
| 38 | - */ |
|
| 39 | - private $activated = false; |
|
| 36 | + /** |
|
| 37 | + * @var bool - Module needs to be activated by some app |
|
| 38 | + */ |
|
| 39 | + private $activated = false; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @inheritdoc |
|
| 43 | - */ |
|
| 44 | - public function start($id, $description) { |
|
| 45 | - if ($this->activated){ |
|
| 46 | - $this->events[$id] = new Event($id, $description, microtime(true)); |
|
| 47 | - } |
|
| 48 | - } |
|
| 41 | + /** |
|
| 42 | + * @inheritdoc |
|
| 43 | + */ |
|
| 44 | + public function start($id, $description) { |
|
| 45 | + if ($this->activated){ |
|
| 46 | + $this->events[$id] = new Event($id, $description, microtime(true)); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @inheritdoc |
|
| 52 | - */ |
|
| 53 | - public function end($id) { |
|
| 54 | - if ($this->activated && isset($this->events[$id])) { |
|
| 55 | - $timing = $this->events[$id]; |
|
| 56 | - $timing->end(microtime(true)); |
|
| 57 | - } |
|
| 58 | - } |
|
| 50 | + /** |
|
| 51 | + * @inheritdoc |
|
| 52 | + */ |
|
| 53 | + public function end($id) { |
|
| 54 | + if ($this->activated && isset($this->events[$id])) { |
|
| 55 | + $timing = $this->events[$id]; |
|
| 56 | + $timing->end(microtime(true)); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @inheritdoc |
|
| 62 | - */ |
|
| 63 | - public function log($id, $description, $start, $end) { |
|
| 64 | - if ($this->activated) { |
|
| 65 | - $this->events[$id] = new Event($id, $description, $start); |
|
| 66 | - $this->events[$id]->end($end); |
|
| 67 | - } |
|
| 68 | - } |
|
| 60 | + /** |
|
| 61 | + * @inheritdoc |
|
| 62 | + */ |
|
| 63 | + public function log($id, $description, $start, $end) { |
|
| 64 | + if ($this->activated) { |
|
| 65 | + $this->events[$id] = new Event($id, $description, $start); |
|
| 66 | + $this->events[$id]->end($end); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @inheritdoc |
|
| 72 | - */ |
|
| 73 | - public function getEvents() { |
|
| 74 | - return $this->events; |
|
| 75 | - } |
|
| 70 | + /** |
|
| 71 | + * @inheritdoc |
|
| 72 | + */ |
|
| 73 | + public function getEvents() { |
|
| 74 | + return $this->events; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * @inheritdoc |
|
| 79 | - */ |
|
| 80 | - public function activate() { |
|
| 81 | - $this->activated = true; |
|
| 82 | - } |
|
| 77 | + /** |
|
| 78 | + * @inheritdoc |
|
| 79 | + */ |
|
| 80 | + public function activate() { |
|
| 81 | + $this->activated = true; |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | * @inheritdoc |
| 43 | 43 | */ |
| 44 | 44 | public function start($id, $description) { |
| 45 | - if ($this->activated){ |
|
| 45 | + if ($this->activated) { |
|
| 46 | 46 | $this->events[$id] = new Event($id, $description, microtime(true)); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -33,68 +33,68 @@ |
||
| 33 | 33 | use OCP\Diagnostics\IQueryLogger; |
| 34 | 34 | |
| 35 | 35 | class QueryLogger implements IQueryLogger { |
| 36 | - /** |
|
| 37 | - * @var \OC\Diagnostics\Query |
|
| 38 | - */ |
|
| 39 | - protected $activeQuery; |
|
| 36 | + /** |
|
| 37 | + * @var \OC\Diagnostics\Query |
|
| 38 | + */ |
|
| 39 | + protected $activeQuery; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var \OC\Diagnostics\Query[] |
|
| 43 | - */ |
|
| 44 | - protected $queries; |
|
| 41 | + /** |
|
| 42 | + * @var \OC\Diagnostics\Query[] |
|
| 43 | + */ |
|
| 44 | + protected $queries; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * QueryLogger constructor. |
|
| 48 | - */ |
|
| 49 | - public function __construct() { |
|
| 50 | - $this->queries = new CappedMemoryCache(1024); |
|
| 51 | - } |
|
| 46 | + /** |
|
| 47 | + * QueryLogger constructor. |
|
| 48 | + */ |
|
| 49 | + public function __construct() { |
|
| 50 | + $this->queries = new CappedMemoryCache(1024); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @var bool - Module needs to be activated by some app |
|
| 56 | - */ |
|
| 57 | - private $activated = false; |
|
| 54 | + /** |
|
| 55 | + * @var bool - Module needs to be activated by some app |
|
| 56 | + */ |
|
| 57 | + private $activated = false; |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * @inheritdoc |
|
| 61 | - */ |
|
| 62 | - public function startQuery($sql, array $params = null, array $types = null) { |
|
| 63 | - if ($this->activated) { |
|
| 64 | - $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); |
|
| 65 | - } |
|
| 66 | - } |
|
| 59 | + /** |
|
| 60 | + * @inheritdoc |
|
| 61 | + */ |
|
| 62 | + public function startQuery($sql, array $params = null, array $types = null) { |
|
| 63 | + if ($this->activated) { |
|
| 64 | + $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack()); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - private function getStack() { |
|
| 69 | - $stack = debug_backtrace(); |
|
| 70 | - array_shift($stack); |
|
| 71 | - array_shift($stack); |
|
| 72 | - array_shift($stack); |
|
| 73 | - return $stack; |
|
| 74 | - } |
|
| 68 | + private function getStack() { |
|
| 69 | + $stack = debug_backtrace(); |
|
| 70 | + array_shift($stack); |
|
| 71 | + array_shift($stack); |
|
| 72 | + array_shift($stack); |
|
| 73 | + return $stack; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * @inheritdoc |
|
| 78 | - */ |
|
| 79 | - public function stopQuery() { |
|
| 80 | - if ($this->activated && $this->activeQuery) { |
|
| 81 | - $this->activeQuery->end(microtime(true)); |
|
| 82 | - $this->queries[] = $this->activeQuery; |
|
| 83 | - $this->activeQuery = null; |
|
| 84 | - } |
|
| 85 | - } |
|
| 76 | + /** |
|
| 77 | + * @inheritdoc |
|
| 78 | + */ |
|
| 79 | + public function stopQuery() { |
|
| 80 | + if ($this->activated && $this->activeQuery) { |
|
| 81 | + $this->activeQuery->end(microtime(true)); |
|
| 82 | + $this->queries[] = $this->activeQuery; |
|
| 83 | + $this->activeQuery = null; |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * @inheritdoc |
|
| 89 | - */ |
|
| 90 | - public function getQueries() { |
|
| 91 | - return $this->queries->getData(); |
|
| 92 | - } |
|
| 87 | + /** |
|
| 88 | + * @inheritdoc |
|
| 89 | + */ |
|
| 90 | + public function getQueries() { |
|
| 91 | + return $this->queries->getData(); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @inheritdoc |
|
| 96 | - */ |
|
| 97 | - public function activate() { |
|
| 98 | - $this->activated = true; |
|
| 99 | - } |
|
| 94 | + /** |
|
| 95 | + * @inheritdoc |
|
| 96 | + */ |
|
| 97 | + public function activate() { |
|
| 98 | + $this->activated = true; |
|
| 99 | + } |
|
| 100 | 100 | } |