You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Server.php 72KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. * @copyright Copyright (c) 2016, Lukas Reschke <lukas@statuscode.ch>
  5. *
  6. * @author Arne Hamann <kontakt+github@arne.email>
  7. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  8. * @author Bart Visscher <bartv@thisnet.nl>
  9. * @author Bernhard Posselt <dev@bernhard-posselt.com>
  10. * @author Bernhard Reiter <ockham@raz.or.at>
  11. * @author Bjoern Schiessle <bjoern@schiessle.org>
  12. * @author Björn Schießle <bjoern@schiessle.org>
  13. * @author Christopher Schäpers <kondou@ts.unde.re>
  14. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  15. * @author Damjan Georgievski <gdamjan@gmail.com>
  16. * @author Daniel Kesselberg <mail@danielkesselberg.de>
  17. * @author Georg Ehrke <oc.list@georgehrke.com>
  18. * @author Joas Schilling <coding@schilljs.com>
  19. * @author John Molakvoæ <skjnldsv@protonmail.com>
  20. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  21. * @author Julius Haertl <jus@bitgrid.net>
  22. * @author Julius Härtl <jus@bitgrid.net>
  23. * @author Lionel Elie Mamane <lionel@mamane.lu>
  24. * @author Lukas Reschke <lukas@statuscode.ch>
  25. * @author Maxence Lange <maxence@artificial-owl.com>
  26. * @author Michael Weimann <mail@michael-weimann.eu>
  27. * @author Morris Jobke <hey@morrisjobke.de>
  28. * @author Piotr Mrówczyński <mrow4a@yahoo.com>
  29. * @author Robin Appelman <robin@icewind.nl>
  30. * @author Robin McCorkell <robin@mccorkell.me.uk>
  31. * @author Roeland Jago Douma <roeland@famdouma.nl>
  32. * @author root <root@localhost.localdomain>
  33. * @author Thomas Müller <thomas.mueller@tmit.eu>
  34. * @author Thomas Tanghus <thomas@tanghus.net>
  35. * @author Tobia De Koninck <tobia@ledfan.be>
  36. * @author Vincent Petry <vincent@nextcloud.com>
  37. *
  38. * @license AGPL-3.0
  39. *
  40. * This code is free software: you can redistribute it and/or modify
  41. * it under the terms of the GNU Affero General Public License, version 3,
  42. * as published by the Free Software Foundation.
  43. *
  44. * This program is distributed in the hope that it will be useful,
  45. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  46. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  47. * GNU Affero General Public License for more details.
  48. *
  49. * You should have received a copy of the GNU Affero General Public License, version 3,
  50. * along with this program. If not, see <http://www.gnu.org/licenses/>
  51. *
  52. */
  53. namespace OC;
  54. use bantu\IniGetWrapper\IniGetWrapper;
  55. use OC\Accounts\AccountManager;
  56. use OC\App\AppManager;
  57. use OC\App\AppStore\Bundles\BundleFetcher;
  58. use OC\App\AppStore\Fetcher\AppFetcher;
  59. use OC\App\AppStore\Fetcher\CategoryFetcher;
  60. use OC\AppFramework\Http\Request;
  61. use OC\AppFramework\Utility\TimeFactory;
  62. use OC\Authentication\Events\LoginFailed;
  63. use OC\Authentication\Listeners\LoginFailedListener;
  64. use OC\Authentication\Listeners\UserLoggedInListener;
  65. use OC\Authentication\LoginCredentials\Store;
  66. use OC\Authentication\Token\IProvider;
  67. use OC\Avatar\AvatarManager;
  68. use OC\Collaboration\Collaborators\GroupPlugin;
  69. use OC\Collaboration\Collaborators\MailPlugin;
  70. use OC\Collaboration\Collaborators\RemoteGroupPlugin;
  71. use OC\Collaboration\Collaborators\RemotePlugin;
  72. use OC\Collaboration\Collaborators\UserPlugin;
  73. use OC\Command\CronBus;
  74. use OC\Comments\ManagerFactory as CommentsManagerFactory;
  75. use OC\Contacts\ContactsMenu\ActionFactory;
  76. use OC\Contacts\ContactsMenu\ContactsStore;
  77. use OC\Dashboard\DashboardManager;
  78. use OC\DB\Connection;
  79. use OC\DB\ConnectionAdapter;
  80. use OC\Diagnostics\EventLogger;
  81. use OC\Diagnostics\QueryLogger;
  82. use OC\EventDispatcher\SymfonyAdapter;
  83. use OC\Federation\CloudFederationFactory;
  84. use OC\Federation\CloudFederationProviderManager;
  85. use OC\Federation\CloudIdManager;
  86. use OC\Files\Config\UserMountCache;
  87. use OC\Files\Config\UserMountCacheListener;
  88. use OC\Files\Mount\CacheMountProvider;
  89. use OC\Files\Mount\LocalHomeMountProvider;
  90. use OC\Files\Mount\ObjectHomeMountProvider;
  91. use OC\Files\Mount\ObjectStorePreviewCacheMountProvider;
  92. use OC\Files\Node\HookConnector;
  93. use OC\Files\Node\LazyRoot;
  94. use OC\Files\Node\Root;
  95. use OC\Files\Storage\StorageFactory;
  96. use OC\Files\Template\TemplateManager;
  97. use OC\Files\Type\Loader;
  98. use OC\Files\View;
  99. use OC\FullTextSearch\FullTextSearchManager;
  100. use OC\Http\Client\ClientService;
  101. use OC\Http\Client\DnsPinMiddleware;
  102. use OC\Http\Client\LocalAddressChecker;
  103. use OC\Http\Client\NegativeDnsCache;
  104. use OC\IntegrityCheck\Checker;
  105. use OC\IntegrityCheck\Helpers\AppLocator;
  106. use OC\IntegrityCheck\Helpers\EnvironmentHelper;
  107. use OC\IntegrityCheck\Helpers\FileAccessHelper;
  108. use OC\LDAP\NullLDAPProviderFactory;
  109. use OC\KnownUser\KnownUserService;
  110. use OC\Lock\DBLockingProvider;
  111. use OC\Lock\MemcacheLockingProvider;
  112. use OC\Lock\NoopLockingProvider;
  113. use OC\Lockdown\LockdownManager;
  114. use OC\Log\LogFactory;
  115. use OC\Log\PsrLoggerAdapter;
  116. use OC\Mail\Mailer;
  117. use OC\Memcache\ArrayCache;
  118. use OC\Memcache\Factory;
  119. use OC\Notification\Manager;
  120. use OC\OCS\DiscoveryService;
  121. use OC\Preview\GeneratorHelper;
  122. use OC\Remote\Api\ApiFactory;
  123. use OC\Remote\InstanceFactory;
  124. use OC\RichObjectStrings\Validator;
  125. use OC\Route\Router;
  126. use OC\Security\Bruteforce\Throttler;
  127. use OC\Security\CertificateManager;
  128. use OC\Security\CredentialsManager;
  129. use OC\Security\Crypto;
  130. use OC\Security\CSP\ContentSecurityPolicyManager;
  131. use OC\Security\CSP\ContentSecurityPolicyNonceManager;
  132. use OC\Security\CSRF\CsrfTokenManager;
  133. use OC\Security\CSRF\TokenStorage\SessionStorage;
  134. use OC\Security\Hasher;
  135. use OC\Security\SecureRandom;
  136. use OC\Security\TrustedDomainHelper;
  137. use OC\Session\CryptoWrapper;
  138. use OC\Share20\ProviderFactory;
  139. use OC\Share20\ShareHelper;
  140. use OC\SystemTag\ManagerFactory as SystemTagManagerFactory;
  141. use OC\Tagging\TagMapper;
  142. use OC\Template\JSCombiner;
  143. use OCA\Theming\ImageManager;
  144. use OCA\Theming\ThemingDefaults;
  145. use OCA\Theming\Util;
  146. use OCA\WorkflowEngine\Service\Logger;
  147. use OCP\Accounts\IAccountManager;
  148. use OCP\App\IAppManager;
  149. use OCP\Authentication\LoginCredentials\IStore;
  150. use OCP\BackgroundJob\IJobList;
  151. use OCP\Collaboration\AutoComplete\IManager;
  152. use OCP\Command\IBus;
  153. use OCP\Comments\ICommentsManager;
  154. use OCP\Contacts\ContactsMenu\IActionFactory;
  155. use OCP\Contacts\ContactsMenu\IContactsStore;
  156. use OCP\Dashboard\IDashboardManager;
  157. use OCP\Defaults;
  158. use OCP\Diagnostics\IEventLogger;
  159. use OCP\Diagnostics\IQueryLogger;
  160. use OCP\Encryption\IFile;
  161. use OCP\Encryption\Keys\IStorage;
  162. use OCP\EventDispatcher\IEventDispatcher;
  163. use OCP\Federation\ICloudFederationFactory;
  164. use OCP\Federation\ICloudFederationProviderManager;
  165. use OCP\Federation\ICloudIdManager;
  166. use OCP\Files\Config\IMountProviderCollection;
  167. use OCP\Files\Config\IUserMountCache;
  168. use OCP\Files\IMimeTypeDetector;
  169. use OCP\Files\IMimeTypeLoader;
  170. use OCP\Files\IRootFolder;
  171. use OCP\Files\Mount\IMountManager;
  172. use OCP\Files\NotFoundException;
  173. use OCP\Files\Storage\IStorageFactory;
  174. use OCP\Files\Template\ITemplateManager;
  175. use OCP\FullTextSearch\IFullTextSearchManager;
  176. use OCP\GlobalScale\IConfig;
  177. use OCP\Group\Events\BeforeGroupCreatedEvent;
  178. use OCP\Group\Events\BeforeGroupDeletedEvent;
  179. use OCP\Group\Events\BeforeUserAddedEvent;
  180. use OCP\Group\Events\BeforeUserRemovedEvent;
  181. use OCP\Group\Events\GroupCreatedEvent;
  182. use OCP\Group\Events\GroupDeletedEvent;
  183. use OCP\Group\Events\UserAddedEvent;
  184. use OCP\Group\Events\UserRemovedEvent;
  185. use OCP\Group\ISubAdmin;
  186. use OCP\Http\Client\IClientService;
  187. use OCP\IAppConfig;
  188. use OCP\IAvatarManager;
  189. use OCP\ICache;
  190. use OCP\ICacheFactory;
  191. use OCP\ICertificateManager;
  192. use OCP\IDateTimeFormatter;
  193. use OCP\IDateTimeZone;
  194. use OCP\IDBConnection;
  195. use OCP\IGroupManager;
  196. use OCP\IInitialStateService;
  197. use OCP\IL10N;
  198. use OCP\ILogger;
  199. use OCP\INavigationManager;
  200. use OCP\IPreview;
  201. use OCP\IRequest;
  202. use OCP\ISearch;
  203. use OCP\IServerContainer;
  204. use OCP\ISession;
  205. use OCP\ITagManager;
  206. use OCP\ITempManager;
  207. use OCP\IURLGenerator;
  208. use OCP\IUser;
  209. use OCP\IUserManager;
  210. use OCP\IUserSession;
  211. use OCP\L10N\IFactory;
  212. use OCP\LDAP\ILDAPProvider;
  213. use OCP\LDAP\ILDAPProviderFactory;
  214. use OCP\Lock\ILockingProvider;
  215. use OCP\Log\ILogFactory;
  216. use OCP\Mail\IMailer;
  217. use OCP\Remote\Api\IApiFactory;
  218. use OCP\Remote\IInstanceFactory;
  219. use OCP\RichObjectStrings\IValidator;
  220. use OCP\Route\IRouter;
  221. use OCP\Security\IContentSecurityPolicyManager;
  222. use OCP\Security\ICredentialsManager;
  223. use OCP\Security\ICrypto;
  224. use OCP\Security\IHasher;
  225. use OCP\Security\ISecureRandom;
  226. use OCP\Share\IShareHelper;
  227. use OCP\SystemTag\ISystemTagManager;
  228. use OCP\SystemTag\ISystemTagObjectMapper;
  229. use OCP\User\Events\BeforePasswordUpdatedEvent;
  230. use OCP\User\Events\BeforeUserCreatedEvent;
  231. use OCP\User\Events\BeforeUserDeletedEvent;
  232. use OCP\User\Events\BeforeUserLoggedInEvent;
  233. use OCP\User\Events\BeforeUserLoggedInWithCookieEvent;
  234. use OCP\User\Events\BeforeUserLoggedOutEvent;
  235. use OCP\User\Events\PasswordUpdatedEvent;
  236. use OCP\User\Events\PostLoginEvent;
  237. use OCP\User\Events\UserChangedEvent;
  238. use OCP\User\Events\UserDeletedEvent;
  239. use OCP\User\Events\UserLoggedInEvent;
  240. use OCP\User\Events\UserLoggedInWithCookieEvent;
  241. use OCP\User\Events\UserLoggedOutEvent;
  242. use Psr\Container\ContainerExceptionInterface;
  243. use Psr\Container\ContainerInterface;
  244. use Psr\Log\LoggerInterface;
  245. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  246. use Symfony\Component\EventDispatcher\GenericEvent;
  247. use OCA\Files_External\Service\UserStoragesService;
  248. use OCA\Files_External\Service\UserGlobalStoragesService;
  249. use OCA\Files_External\Service\GlobalStoragesService;
  250. use OCA\Files_External\Service\BackendService;
  251. /**
  252. * Class Server
  253. *
  254. * @package OC
  255. *
  256. * TODO: hookup all manager classes
  257. */
  258. class Server extends ServerContainer implements IServerContainer {
  259. /** @var string */
  260. private $webRoot;
  261. /**
  262. * @param string $webRoot
  263. * @param \OC\Config $config
  264. */
  265. public function __construct($webRoot, \OC\Config $config) {
  266. parent::__construct();
  267. $this->webRoot = $webRoot;
  268. // To find out if we are running from CLI or not
  269. $this->registerParameter('isCLI', \OC::$CLI);
  270. $this->registerParameter('serverRoot', \OC::$SERVERROOT);
  271. $this->registerService(ContainerInterface::class, function (ContainerInterface $c) {
  272. return $c;
  273. });
  274. $this->registerService(\OCP\IServerContainer::class, function (ContainerInterface $c) {
  275. return $c;
  276. });
  277. $this->registerAlias(\OCP\Calendar\IManager::class, \OC\Calendar\Manager::class);
  278. /** @deprecated 19.0.0 */
  279. $this->registerDeprecatedAlias('CalendarManager', \OC\Calendar\Manager::class);
  280. $this->registerAlias(\OCP\Calendar\Resource\IManager::class, \OC\Calendar\Resource\Manager::class);
  281. /** @deprecated 19.0.0 */
  282. $this->registerDeprecatedAlias('CalendarResourceBackendManager', \OC\Calendar\Resource\Manager::class);
  283. $this->registerAlias(\OCP\Calendar\Room\IManager::class, \OC\Calendar\Room\Manager::class);
  284. /** @deprecated 19.0.0 */
  285. $this->registerDeprecatedAlias('CalendarRoomBackendManager', \OC\Calendar\Room\Manager::class);
  286. $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class);
  287. /** @deprecated 19.0.0 */
  288. $this->registerDeprecatedAlias('ContactsManager', \OCP\Contacts\IManager::class);
  289. $this->registerAlias(\OCP\DirectEditing\IManager::class, \OC\DirectEditing\Manager::class);
  290. $this->registerAlias(ITemplateManager::class, TemplateManager::class);
  291. $this->registerAlias(IActionFactory::class, ActionFactory::class);
  292. $this->registerService(View::class, function (Server $c) {
  293. return new View();
  294. }, false);
  295. $this->registerService(IPreview::class, function (ContainerInterface $c) {
  296. return new PreviewManager(
  297. $c->get(\OCP\IConfig::class),
  298. $c->get(IRootFolder::class),
  299. new \OC\Preview\Storage\Root(
  300. $c->get(IRootFolder::class),
  301. $c->get(SystemConfig::class)
  302. ),
  303. $c->get(SymfonyAdapter::class),
  304. $c->get(GeneratorHelper::class),
  305. $c->get(ISession::class)->get('user_id')
  306. );
  307. });
  308. /** @deprecated 19.0.0 */
  309. $this->registerDeprecatedAlias('PreviewManager', IPreview::class);
  310. $this->registerService(\OC\Preview\Watcher::class, function (ContainerInterface $c) {
  311. return new \OC\Preview\Watcher(
  312. new \OC\Preview\Storage\Root(
  313. $c->get(IRootFolder::class),
  314. $c->get(SystemConfig::class)
  315. )
  316. );
  317. });
  318. $this->registerService(\OCP\Encryption\IManager::class, function (Server $c) {
  319. $view = new View();
  320. $util = new Encryption\Util(
  321. $view,
  322. $c->get(IUserManager::class),
  323. $c->get(IGroupManager::class),
  324. $c->get(\OCP\IConfig::class)
  325. );
  326. return new Encryption\Manager(
  327. $c->get(\OCP\IConfig::class),
  328. $c->get(ILogger::class),
  329. $c->getL10N('core'),
  330. new View(),
  331. $util,
  332. new ArrayCache()
  333. );
  334. });
  335. /** @deprecated 19.0.0 */
  336. $this->registerDeprecatedAlias('EncryptionManager', \OCP\Encryption\IManager::class);
  337. /** @deprecated 21.0.0 */
  338. $this->registerDeprecatedAlias('EncryptionFileHelper', IFile::class);
  339. $this->registerService(IFile::class, function (ContainerInterface $c) {
  340. $util = new Encryption\Util(
  341. new View(),
  342. $c->get(IUserManager::class),
  343. $c->get(IGroupManager::class),
  344. $c->get(\OCP\IConfig::class)
  345. );
  346. return new Encryption\File(
  347. $util,
  348. $c->get(IRootFolder::class),
  349. $c->get(\OCP\Share\IManager::class)
  350. );
  351. });
  352. /** @deprecated 21.0.0 */
  353. $this->registerDeprecatedAlias('EncryptionKeyStorage', IStorage::class);
  354. $this->registerService(IStorage::class, function (ContainerInterface $c) {
  355. $view = new View();
  356. $util = new Encryption\Util(
  357. $view,
  358. $c->get(IUserManager::class),
  359. $c->get(IGroupManager::class),
  360. $c->get(\OCP\IConfig::class)
  361. );
  362. return new Encryption\Keys\Storage(
  363. $view,
  364. $util,
  365. $c->get(ICrypto::class),
  366. $c->get(\OCP\IConfig::class)
  367. );
  368. });
  369. /** @deprecated 20.0.0 */
  370. $this->registerDeprecatedAlias('TagMapper', TagMapper::class);
  371. $this->registerAlias(\OCP\ITagManager::class, TagManager::class);
  372. /** @deprecated 19.0.0 */
  373. $this->registerDeprecatedAlias('TagManager', \OCP\ITagManager::class);
  374. $this->registerService('SystemTagManagerFactory', function (ContainerInterface $c) {
  375. /** @var \OCP\IConfig $config */
  376. $config = $c->get(\OCP\IConfig::class);
  377. $factoryClass = $config->getSystemValue('systemtags.managerFactory', SystemTagManagerFactory::class);
  378. return new $factoryClass($this);
  379. });
  380. $this->registerService(ISystemTagManager::class, function (ContainerInterface $c) {
  381. return $c->get('SystemTagManagerFactory')->getManager();
  382. });
  383. /** @deprecated 19.0.0 */
  384. $this->registerDeprecatedAlias('SystemTagManager', ISystemTagManager::class);
  385. $this->registerService(ISystemTagObjectMapper::class, function (ContainerInterface $c) {
  386. return $c->get('SystemTagManagerFactory')->getObjectMapper();
  387. });
  388. $this->registerService('RootFolder', function (ContainerInterface $c) {
  389. $manager = \OC\Files\Filesystem::getMountManager(null);
  390. $view = new View();
  391. $root = new Root(
  392. $manager,
  393. $view,
  394. null,
  395. $c->get(IUserMountCache::class),
  396. $this->get(ILogger::class),
  397. $this->get(IUserManager::class)
  398. );
  399. $previewConnector = new \OC\Preview\WatcherConnector(
  400. $root,
  401. $c->get(SystemConfig::class)
  402. );
  403. $previewConnector->connectWatcher();
  404. return $root;
  405. });
  406. $this->registerService(HookConnector::class, function (ContainerInterface $c) {
  407. return new HookConnector(
  408. $c->get(IRootFolder::class),
  409. new View(),
  410. $c->get(\OC\EventDispatcher\SymfonyAdapter::class),
  411. $c->get(IEventDispatcher::class)
  412. );
  413. });
  414. /** @deprecated 19.0.0 */
  415. $this->registerDeprecatedAlias('SystemTagObjectMapper', ISystemTagObjectMapper::class);
  416. $this->registerService(IRootFolder::class, function (ContainerInterface $c) {
  417. return new LazyRoot(function () use ($c) {
  418. return $c->get('RootFolder');
  419. });
  420. });
  421. /** @deprecated 19.0.0 */
  422. $this->registerDeprecatedAlias('LazyRootFolder', IRootFolder::class);
  423. /** @deprecated 19.0.0 */
  424. $this->registerDeprecatedAlias('UserManager', \OC\User\Manager::class);
  425. $this->registerAlias(\OCP\IUserManager::class, \OC\User\Manager::class);
  426. $this->registerService(\OCP\IGroupManager::class, function (ContainerInterface $c) {
  427. $groupManager = new \OC\Group\Manager($this->get(IUserManager::class), $c->get(SymfonyAdapter::class), $this->get(ILogger::class));
  428. $groupManager->listen('\OC\Group', 'preCreate', function ($gid) {
  429. /** @var IEventDispatcher $dispatcher */
  430. $dispatcher = $this->get(IEventDispatcher::class);
  431. $dispatcher->dispatchTyped(new BeforeGroupCreatedEvent($gid));
  432. });
  433. $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $group) {
  434. /** @var IEventDispatcher $dispatcher */
  435. $dispatcher = $this->get(IEventDispatcher::class);
  436. $dispatcher->dispatchTyped(new GroupCreatedEvent($group));
  437. });
  438. $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) {
  439. /** @var IEventDispatcher $dispatcher */
  440. $dispatcher = $this->get(IEventDispatcher::class);
  441. $dispatcher->dispatchTyped(new BeforeGroupDeletedEvent($group));
  442. });
  443. $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) {
  444. /** @var IEventDispatcher $dispatcher */
  445. $dispatcher = $this->get(IEventDispatcher::class);
  446. $dispatcher->dispatchTyped(new GroupDeletedEvent($group));
  447. });
  448. $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
  449. /** @var IEventDispatcher $dispatcher */
  450. $dispatcher = $this->get(IEventDispatcher::class);
  451. $dispatcher->dispatchTyped(new BeforeUserAddedEvent($group, $user));
  452. });
  453. $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) {
  454. /** @var IEventDispatcher $dispatcher */
  455. $dispatcher = $this->get(IEventDispatcher::class);
  456. $dispatcher->dispatchTyped(new UserAddedEvent($group, $user));
  457. });
  458. $groupManager->listen('\OC\Group', 'preRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
  459. /** @var IEventDispatcher $dispatcher */
  460. $dispatcher = $this->get(IEventDispatcher::class);
  461. $dispatcher->dispatchTyped(new BeforeUserRemovedEvent($group, $user));
  462. });
  463. $groupManager->listen('\OC\Group', 'postRemoveUser', function (\OC\Group\Group $group, \OC\User\User $user) {
  464. /** @var IEventDispatcher $dispatcher */
  465. $dispatcher = $this->get(IEventDispatcher::class);
  466. $dispatcher->dispatchTyped(new UserRemovedEvent($group, $user));
  467. });
  468. return $groupManager;
  469. });
  470. /** @deprecated 19.0.0 */
  471. $this->registerDeprecatedAlias('GroupManager', \OCP\IGroupManager::class);
  472. $this->registerService(Store::class, function (ContainerInterface $c) {
  473. $session = $c->get(ISession::class);
  474. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  475. $tokenProvider = $c->get(IProvider::class);
  476. } else {
  477. $tokenProvider = null;
  478. }
  479. $logger = $c->get(LoggerInterface::class);
  480. return new Store($session, $logger, $tokenProvider);
  481. });
  482. $this->registerAlias(IStore::class, Store::class);
  483. $this->registerAlias(IProvider::class, Authentication\Token\Manager::class);
  484. $this->registerService(\OC\User\Session::class, function (Server $c) {
  485. $manager = $c->get(IUserManager::class);
  486. $session = new \OC\Session\Memory('');
  487. $timeFactory = new TimeFactory();
  488. // Token providers might require a working database. This code
  489. // might however be called when ownCloud is not yet setup.
  490. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  491. $defaultTokenProvider = $c->get(IProvider::class);
  492. } else {
  493. $defaultTokenProvider = null;
  494. }
  495. $legacyDispatcher = $c->get(SymfonyAdapter::class);
  496. $userSession = new \OC\User\Session(
  497. $manager,
  498. $session,
  499. $timeFactory,
  500. $defaultTokenProvider,
  501. $c->get(\OCP\IConfig::class),
  502. $c->get(ISecureRandom::class),
  503. $c->getLockdownManager(),
  504. $c->get(ILogger::class),
  505. $c->get(IEventDispatcher::class)
  506. );
  507. /** @deprecated 21.0.0 use BeforeUserCreatedEvent event with the IEventDispatcher instead */
  508. $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
  509. \OC_Hook::emit('OC_User', 'pre_createUser', ['run' => true, 'uid' => $uid, 'password' => $password]);
  510. });
  511. /** @deprecated 21.0.0 use UserCreatedEvent event with the IEventDispatcher instead */
  512. $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) {
  513. /** @var \OC\User\User $user */
  514. \OC_Hook::emit('OC_User', 'post_createUser', ['uid' => $user->getUID(), 'password' => $password]);
  515. });
  516. /** @deprecated 21.0.0 use BeforeUserDeletedEvent event with the IEventDispatcher instead */
  517. $userSession->listen('\OC\User', 'preDelete', function ($user) use ($legacyDispatcher) {
  518. /** @var \OC\User\User $user */
  519. \OC_Hook::emit('OC_User', 'pre_deleteUser', ['run' => true, 'uid' => $user->getUID()]);
  520. $legacyDispatcher->dispatch('OCP\IUser::preDelete', new GenericEvent($user));
  521. });
  522. /** @deprecated 21.0.0 use UserDeletedEvent event with the IEventDispatcher instead */
  523. $userSession->listen('\OC\User', 'postDelete', function ($user) {
  524. /** @var \OC\User\User $user */
  525. \OC_Hook::emit('OC_User', 'post_deleteUser', ['uid' => $user->getUID()]);
  526. });
  527. $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) {
  528. /** @var \OC\User\User $user */
  529. \OC_Hook::emit('OC_User', 'pre_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
  530. /** @var IEventDispatcher $dispatcher */
  531. $dispatcher = $this->get(IEventDispatcher::class);
  532. $dispatcher->dispatchTyped(new BeforePasswordUpdatedEvent($user, $password, $recoveryPassword));
  533. });
  534. $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) {
  535. /** @var \OC\User\User $user */
  536. \OC_Hook::emit('OC_User', 'post_setPassword', ['run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword]);
  537. /** @var IEventDispatcher $dispatcher */
  538. $dispatcher = $this->get(IEventDispatcher::class);
  539. $dispatcher->dispatchTyped(new PasswordUpdatedEvent($user, $password, $recoveryPassword));
  540. });
  541. $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) {
  542. \OC_Hook::emit('OC_User', 'pre_login', ['run' => true, 'uid' => $uid, 'password' => $password]);
  543. /** @var IEventDispatcher $dispatcher */
  544. $dispatcher = $this->get(IEventDispatcher::class);
  545. $dispatcher->dispatchTyped(new BeforeUserLoggedInEvent($uid, $password));
  546. });
  547. $userSession->listen('\OC\User', 'postLogin', function ($user, $loginName, $password, $isTokenLogin) {
  548. /** @var \OC\User\User $user */
  549. \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'loginName' => $loginName, 'password' => $password, 'isTokenLogin' => $isTokenLogin]);
  550. /** @var IEventDispatcher $dispatcher */
  551. $dispatcher = $this->get(IEventDispatcher::class);
  552. $dispatcher->dispatchTyped(new UserLoggedInEvent($user, $loginName, $password, $isTokenLogin));
  553. });
  554. $userSession->listen('\OC\User', 'preRememberedLogin', function ($uid) {
  555. /** @var IEventDispatcher $dispatcher */
  556. $dispatcher = $this->get(IEventDispatcher::class);
  557. $dispatcher->dispatchTyped(new BeforeUserLoggedInWithCookieEvent($uid));
  558. });
  559. $userSession->listen('\OC\User', 'postRememberedLogin', function ($user, $password) {
  560. /** @var \OC\User\User $user */
  561. \OC_Hook::emit('OC_User', 'post_login', ['run' => true, 'uid' => $user->getUID(), 'password' => $password]);
  562. /** @var IEventDispatcher $dispatcher */
  563. $dispatcher = $this->get(IEventDispatcher::class);
  564. $dispatcher->dispatchTyped(new UserLoggedInWithCookieEvent($user, $password));
  565. });
  566. $userSession->listen('\OC\User', 'logout', function ($user) {
  567. \OC_Hook::emit('OC_User', 'logout', []);
  568. /** @var IEventDispatcher $dispatcher */
  569. $dispatcher = $this->get(IEventDispatcher::class);
  570. $dispatcher->dispatchTyped(new BeforeUserLoggedOutEvent($user));
  571. });
  572. $userSession->listen('\OC\User', 'postLogout', function ($user) {
  573. /** @var IEventDispatcher $dispatcher */
  574. $dispatcher = $this->get(IEventDispatcher::class);
  575. $dispatcher->dispatchTyped(new UserLoggedOutEvent($user));
  576. });
  577. $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
  578. /** @var \OC\User\User $user */
  579. \OC_Hook::emit('OC_User', 'changeUser', ['run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue]);
  580. /** @var IEventDispatcher $dispatcher */
  581. $dispatcher = $this->get(IEventDispatcher::class);
  582. $dispatcher->dispatchTyped(new UserChangedEvent($user, $feature, $value, $oldValue));
  583. });
  584. return $userSession;
  585. });
  586. $this->registerAlias(\OCP\IUserSession::class, \OC\User\Session::class);
  587. /** @deprecated 19.0.0 */
  588. $this->registerDeprecatedAlias('UserSession', \OC\User\Session::class);
  589. $this->registerAlias(\OCP\Authentication\TwoFactorAuth\IRegistry::class, \OC\Authentication\TwoFactorAuth\Registry::class);
  590. $this->registerAlias(INavigationManager::class, \OC\NavigationManager::class);
  591. /** @deprecated 19.0.0 */
  592. $this->registerDeprecatedAlias('NavigationManager', INavigationManager::class);
  593. /** @deprecated 19.0.0 */
  594. $this->registerDeprecatedAlias('AllConfig', \OC\AllConfig::class);
  595. $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class);
  596. $this->registerService(\OC\SystemConfig::class, function ($c) use ($config) {
  597. return new \OC\SystemConfig($config);
  598. });
  599. /** @deprecated 19.0.0 */
  600. $this->registerDeprecatedAlias('SystemConfig', \OC\SystemConfig::class);
  601. /** @deprecated 19.0.0 */
  602. $this->registerDeprecatedAlias('AppConfig', \OC\AppConfig::class);
  603. $this->registerAlias(IAppConfig::class, \OC\AppConfig::class);
  604. $this->registerService(IFactory::class, function (Server $c) {
  605. return new \OC\L10N\Factory(
  606. $c->get(\OCP\IConfig::class),
  607. $c->getRequest(),
  608. $c->get(IUserSession::class),
  609. \OC::$SERVERROOT
  610. );
  611. });
  612. /** @deprecated 19.0.0 */
  613. $this->registerDeprecatedAlias('L10NFactory', IFactory::class);
  614. $this->registerAlias(IURLGenerator::class, URLGenerator::class);
  615. /** @deprecated 19.0.0 */
  616. $this->registerDeprecatedAlias('URLGenerator', IURLGenerator::class);
  617. /** @deprecated 19.0.0 */
  618. $this->registerDeprecatedAlias('AppFetcher', AppFetcher::class);
  619. /** @deprecated 19.0.0 */
  620. $this->registerDeprecatedAlias('CategoryFetcher', CategoryFetcher::class);
  621. $this->registerService(ICache::class, function ($c) {
  622. return new Cache\File();
  623. });
  624. /** @deprecated 19.0.0 */
  625. $this->registerDeprecatedAlias('UserCache', ICache::class);
  626. $this->registerService(Factory::class, function (Server $c) {
  627. $arrayCacheFactory = new \OC\Memcache\Factory('', $c->get(ILogger::class),
  628. ArrayCache::class,
  629. ArrayCache::class,
  630. ArrayCache::class
  631. );
  632. /** @var \OCP\IConfig $config */
  633. $config = $c->get(\OCP\IConfig::class);
  634. if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  635. $v = \OC_App::getAppVersions();
  636. $v['core'] = implode(',', \OC_Util::getVersion());
  637. $version = implode(',', $v);
  638. $instanceId = \OC_Util::getInstanceId();
  639. $path = \OC::$SERVERROOT;
  640. $prefix = md5($instanceId . '-' . $version . '-' . $path);
  641. return new \OC\Memcache\Factory($prefix, $c->get(ILogger::class),
  642. $config->getSystemValue('memcache.local', null),
  643. $config->getSystemValue('memcache.distributed', null),
  644. $config->getSystemValue('memcache.locking', null)
  645. );
  646. }
  647. return $arrayCacheFactory;
  648. });
  649. /** @deprecated 19.0.0 */
  650. $this->registerDeprecatedAlias('MemCacheFactory', Factory::class);
  651. $this->registerAlias(ICacheFactory::class, Factory::class);
  652. $this->registerService('RedisFactory', function (Server $c) {
  653. $systemConfig = $c->get(SystemConfig::class);
  654. return new RedisFactory($systemConfig);
  655. });
  656. $this->registerService(\OCP\Activity\IManager::class, function (Server $c) {
  657. $l10n = $this->get(IFactory::class)->get('lib');
  658. return new \OC\Activity\Manager(
  659. $c->getRequest(),
  660. $c->get(IUserSession::class),
  661. $c->get(\OCP\IConfig::class),
  662. $c->get(IValidator::class),
  663. $l10n
  664. );
  665. });
  666. /** @deprecated 19.0.0 */
  667. $this->registerDeprecatedAlias('ActivityManager', \OCP\Activity\IManager::class);
  668. $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) {
  669. return new \OC\Activity\EventMerger(
  670. $c->getL10N('lib')
  671. );
  672. });
  673. $this->registerAlias(IValidator::class, Validator::class);
  674. $this->registerService(AvatarManager::class, function (Server $c) {
  675. return new AvatarManager(
  676. $c->get(IUserSession::class),
  677. $c->get(\OC\User\Manager::class),
  678. $c->getAppDataDir('avatar'),
  679. $c->getL10N('lib'),
  680. $c->get(LoggerInterface::class),
  681. $c->get(\OCP\IConfig::class),
  682. $c->get(IAccountManager::class),
  683. $c->get(KnownUserService::class)
  684. );
  685. });
  686. $this->registerAlias(IAvatarManager::class, AvatarManager::class);
  687. /** @deprecated 19.0.0 */
  688. $this->registerDeprecatedAlias('AvatarManager', AvatarManager::class);
  689. $this->registerAlias(\OCP\Support\CrashReport\IRegistry::class, \OC\Support\CrashReport\Registry::class);
  690. $this->registerAlias(\OCP\Support\Subscription\IRegistry::class, \OC\Support\Subscription\Registry::class);
  691. $this->registerService(\OC\Log::class, function (Server $c) {
  692. $logType = $c->get(AllConfig::class)->getSystemValue('log_type', 'file');
  693. $factory = new LogFactory($c, $this->get(SystemConfig::class));
  694. $logger = $factory->get($logType);
  695. $registry = $c->get(\OCP\Support\CrashReport\IRegistry::class);
  696. return new Log($logger, $this->get(SystemConfig::class), null, $registry);
  697. });
  698. $this->registerAlias(ILogger::class, \OC\Log::class);
  699. /** @deprecated 19.0.0 */
  700. $this->registerDeprecatedAlias('Logger', \OC\Log::class);
  701. // PSR-3 logger
  702. $this->registerAlias(LoggerInterface::class, PsrLoggerAdapter::class);
  703. $this->registerService(ILogFactory::class, function (Server $c) {
  704. return new LogFactory($c, $this->get(SystemConfig::class));
  705. });
  706. $this->registerAlias(IJobList::class, \OC\BackgroundJob\JobList::class);
  707. /** @deprecated 19.0.0 */
  708. $this->registerDeprecatedAlias('JobList', IJobList::class);
  709. $this->registerService(Router::class, function (Server $c) {
  710. $cacheFactory = $c->get(ICacheFactory::class);
  711. $logger = $c->get(ILogger::class);
  712. if ($cacheFactory->isLocalCacheAvailable()) {
  713. $router = new \OC\Route\CachingRouter($cacheFactory->createLocal('route'), $logger);
  714. } else {
  715. $router = new \OC\Route\Router($logger);
  716. }
  717. return $router;
  718. });
  719. $this->registerAlias(IRouter::class, Router::class);
  720. /** @deprecated 19.0.0 */
  721. $this->registerDeprecatedAlias('Router', IRouter::class);
  722. $this->registerAlias(ISearch::class, Search::class);
  723. /** @deprecated 19.0.0 */
  724. $this->registerDeprecatedAlias('Search', ISearch::class);
  725. $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function ($c) {
  726. return new \OC\Security\RateLimiting\Backend\MemoryCache(
  727. $this->get(ICacheFactory::class),
  728. new \OC\AppFramework\Utility\TimeFactory()
  729. );
  730. });
  731. $this->registerAlias(\OCP\Security\ISecureRandom::class, SecureRandom::class);
  732. /** @deprecated 19.0.0 */
  733. $this->registerDeprecatedAlias('SecureRandom', \OCP\Security\ISecureRandom::class);
  734. $this->registerAlias(ICrypto::class, Crypto::class);
  735. /** @deprecated 19.0.0 */
  736. $this->registerDeprecatedAlias('Crypto', ICrypto::class);
  737. $this->registerAlias(IHasher::class, Hasher::class);
  738. /** @deprecated 19.0.0 */
  739. $this->registerDeprecatedAlias('Hasher', IHasher::class);
  740. $this->registerAlias(ICredentialsManager::class, CredentialsManager::class);
  741. /** @deprecated 19.0.0 */
  742. $this->registerDeprecatedAlias('CredentialsManager', ICredentialsManager::class);
  743. $this->registerAlias(IDBConnection::class, ConnectionAdapter::class);
  744. $this->registerService(Connection::class, function (Server $c) {
  745. $systemConfig = $c->get(SystemConfig::class);
  746. $factory = new \OC\DB\ConnectionFactory($systemConfig);
  747. $type = $systemConfig->getValue('dbtype', 'sqlite');
  748. if (!$factory->isValidType($type)) {
  749. throw new \OC\DatabaseException('Invalid database type');
  750. }
  751. $connectionParams = $factory->createConnectionParams();
  752. $connection = $factory->getConnection($type, $connectionParams);
  753. $connection->getConfiguration()->setSQLLogger($c->getQueryLogger());
  754. return $connection;
  755. });
  756. /** @deprecated 19.0.0 */
  757. $this->registerDeprecatedAlias('DatabaseConnection', IDBConnection::class);
  758. $this->registerAlias(ICertificateManager::class, CertificateManager::class);
  759. $this->registerAlias(IClientService::class, ClientService::class);
  760. $this->registerService(LocalAddressChecker::class, function (ContainerInterface $c) {
  761. return new LocalAddressChecker(
  762. $c->get(ILogger::class),
  763. );
  764. });
  765. $this->registerService(NegativeDnsCache::class, function (ContainerInterface $c) {
  766. return new NegativeDnsCache(
  767. $c->get(ICacheFactory::class),
  768. );
  769. });
  770. $this->registerService(DnsPinMiddleware::class, function (ContainerInterface $c) {
  771. return new DnsPinMiddleware(
  772. $c->get(NegativeDnsCache::class),
  773. $c->get(LocalAddressChecker::class)
  774. );
  775. });
  776. $this->registerDeprecatedAlias('HttpClientService', IClientService::class);
  777. $this->registerService(IEventLogger::class, function (ContainerInterface $c) {
  778. $eventLogger = new EventLogger();
  779. if ($c->get(SystemConfig::class)->getValue('debug', false)) {
  780. // In debug mode, module is being activated by default
  781. $eventLogger->activate();
  782. }
  783. return $eventLogger;
  784. });
  785. /** @deprecated 19.0.0 */
  786. $this->registerDeprecatedAlias('EventLogger', IEventLogger::class);
  787. $this->registerService(IQueryLogger::class, function (ContainerInterface $c) {
  788. $queryLogger = new QueryLogger();
  789. if ($c->get(SystemConfig::class)->getValue('debug', false)) {
  790. // In debug mode, module is being activated by default
  791. $queryLogger->activate();
  792. }
  793. return $queryLogger;
  794. });
  795. /** @deprecated 19.0.0 */
  796. $this->registerDeprecatedAlias('QueryLogger', IQueryLogger::class);
  797. /** @deprecated 19.0.0 */
  798. $this->registerDeprecatedAlias('TempManager', TempManager::class);
  799. $this->registerAlias(ITempManager::class, TempManager::class);
  800. $this->registerService(AppManager::class, function (ContainerInterface $c) {
  801. // TODO: use auto-wiring
  802. return new \OC\App\AppManager(
  803. $c->get(IUserSession::class),
  804. $c->get(\OCP\IConfig::class),
  805. $c->get(\OC\AppConfig::class),
  806. $c->get(IGroupManager::class),
  807. $c->get(ICacheFactory::class),
  808. $c->get(SymfonyAdapter::class),
  809. $c->get(LoggerInterface::class)
  810. );
  811. });
  812. /** @deprecated 19.0.0 */
  813. $this->registerDeprecatedAlias('AppManager', AppManager::class);
  814. $this->registerAlias(IAppManager::class, AppManager::class);
  815. $this->registerAlias(IDateTimeZone::class, DateTimeZone::class);
  816. /** @deprecated 19.0.0 */
  817. $this->registerDeprecatedAlias('DateTimeZone', IDateTimeZone::class);
  818. $this->registerService(IDateTimeFormatter::class, function (Server $c) {
  819. $language = $c->get(\OCP\IConfig::class)->getUserValue($c->get(ISession::class)->get('user_id'), 'core', 'lang', null);
  820. return new DateTimeFormatter(
  821. $c->get(IDateTimeZone::class)->getTimeZone(),
  822. $c->getL10N('lib', $language)
  823. );
  824. });
  825. /** @deprecated 19.0.0 */
  826. $this->registerDeprecatedAlias('DateTimeFormatter', IDateTimeFormatter::class);
  827. $this->registerService(IUserMountCache::class, function (ContainerInterface $c) {
  828. $mountCache = new UserMountCache(
  829. $c->get(IDBConnection::class),
  830. $c->get(IUserManager::class),
  831. $c->get(ILogger::class)
  832. );
  833. $listener = new UserMountCacheListener($mountCache);
  834. $listener->listen($c->get(IUserManager::class));
  835. return $mountCache;
  836. });
  837. /** @deprecated 19.0.0 */
  838. $this->registerDeprecatedAlias('UserMountCache', IUserMountCache::class);
  839. $this->registerService(IMountProviderCollection::class, function (ContainerInterface $c) {
  840. $loader = \OC\Files\Filesystem::getLoader();
  841. $mountCache = $c->get(IUserMountCache::class);
  842. $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache);
  843. // builtin providers
  844. $config = $c->get(\OCP\IConfig::class);
  845. $logger = $c->get(ILogger::class);
  846. $manager->registerProvider(new CacheMountProvider($config));
  847. $manager->registerHomeProvider(new LocalHomeMountProvider());
  848. $manager->registerHomeProvider(new ObjectHomeMountProvider($config));
  849. $manager->registerRootProvider(new ObjectStorePreviewCacheMountProvider($logger, $config));
  850. return $manager;
  851. });
  852. /** @deprecated 19.0.0 */
  853. $this->registerDeprecatedAlias('MountConfigManager', IMountProviderCollection::class);
  854. /** @deprecated 20.0.0 */
  855. $this->registerDeprecatedAlias('IniWrapper', IniGetWrapper::class);
  856. $this->registerService(IBus::class, function (ContainerInterface $c) {
  857. $busClass = $c->get(\OCP\IConfig::class)->getSystemValue('commandbus');
  858. if ($busClass) {
  859. [$app, $class] = explode('::', $busClass, 2);
  860. if ($c->get(IAppManager::class)->isInstalled($app)) {
  861. \OC_App::loadApp($app);
  862. return $c->get($class);
  863. } else {
  864. throw new ServiceUnavailableException("The app providing the command bus ($app) is not enabled");
  865. }
  866. } else {
  867. $jobList = $c->get(IJobList::class);
  868. return new CronBus($jobList);
  869. }
  870. });
  871. $this->registerDeprecatedAlias('AsyncCommandBus', IBus::class);
  872. /** @deprecated 20.0.0 */
  873. $this->registerDeprecatedAlias('TrustedDomainHelper', TrustedDomainHelper::class);
  874. /** @deprecated 19.0.0 */
  875. $this->registerDeprecatedAlias('Throttler', Throttler::class);
  876. $this->registerService('IntegrityCodeChecker', function (ContainerInterface $c) {
  877. // IConfig and IAppManager requires a working database. This code
  878. // might however be called when ownCloud is not yet setup.
  879. if (\OC::$server->get(SystemConfig::class)->getValue('installed', false)) {
  880. $config = $c->get(\OCP\IConfig::class);
  881. $appManager = $c->get(IAppManager::class);
  882. } else {
  883. $config = null;
  884. $appManager = null;
  885. }
  886. return new Checker(
  887. new EnvironmentHelper(),
  888. new FileAccessHelper(),
  889. new AppLocator(),
  890. $config,
  891. $c->get(ICacheFactory::class),
  892. $appManager,
  893. $c->get(IMimeTypeDetector::class)
  894. );
  895. });
  896. $this->registerService(\OCP\IRequest::class, function (ContainerInterface $c) {
  897. if (isset($this['urlParams'])) {
  898. $urlParams = $this['urlParams'];
  899. } else {
  900. $urlParams = [];
  901. }
  902. if (defined('PHPUNIT_RUN') && PHPUNIT_RUN
  903. && in_array('fakeinput', stream_get_wrappers())
  904. ) {
  905. $stream = 'fakeinput://data';
  906. } else {
  907. $stream = 'php://input';
  908. }
  909. return new Request(
  910. [
  911. 'get' => $_GET,
  912. 'post' => $_POST,
  913. 'files' => $_FILES,
  914. 'server' => $_SERVER,
  915. 'env' => $_ENV,
  916. 'cookies' => $_COOKIE,
  917. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  918. ? $_SERVER['REQUEST_METHOD']
  919. : '',
  920. 'urlParams' => $urlParams,
  921. ],
  922. $this->get(ISecureRandom::class),
  923. $this->get(\OCP\IConfig::class),
  924. $this->get(CsrfTokenManager::class),
  925. $stream
  926. );
  927. });
  928. /** @deprecated 19.0.0 */
  929. $this->registerDeprecatedAlias('Request', \OCP\IRequest::class);
  930. $this->registerService(IMailer::class, function (Server $c) {
  931. return new Mailer(
  932. $c->get(\OCP\IConfig::class),
  933. $c->get(ILogger::class),
  934. $c->get(Defaults::class),
  935. $c->get(IURLGenerator::class),
  936. $c->getL10N('lib'),
  937. $c->get(IEventDispatcher::class),
  938. $c->get(IFactory::class)
  939. );
  940. });
  941. /** @deprecated 19.0.0 */
  942. $this->registerDeprecatedAlias('Mailer', IMailer::class);
  943. /** @deprecated 21.0.0 */
  944. $this->registerDeprecatedAlias('LDAPProvider', ILDAPProvider::class);
  945. $this->registerService(ILDAPProviderFactory::class, function (ContainerInterface $c) {
  946. $config = $c->get(\OCP\IConfig::class);
  947. $factoryClass = $config->getSystemValue('ldapProviderFactory', null);
  948. if (is_null($factoryClass) || !class_exists($factoryClass)) {
  949. return new NullLDAPProviderFactory($this);
  950. }
  951. /** @var \OCP\LDAP\ILDAPProviderFactory $factory */
  952. return new $factoryClass($this);
  953. });
  954. $this->registerService(ILDAPProvider::class, function (ContainerInterface $c) {
  955. $factory = $c->get(ILDAPProviderFactory::class);
  956. return $factory->getLDAPProvider();
  957. });
  958. $this->registerService(ILockingProvider::class, function (ContainerInterface $c) {
  959. $ini = $c->get(IniGetWrapper::class);
  960. $config = $c->get(\OCP\IConfig::class);
  961. $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time')));
  962. if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) {
  963. /** @var \OC\Memcache\Factory $memcacheFactory */
  964. $memcacheFactory = $c->get(ICacheFactory::class);
  965. $memcache = $memcacheFactory->createLocking('lock');
  966. if (!($memcache instanceof \OC\Memcache\NullCache)) {
  967. return new MemcacheLockingProvider($memcache, $ttl);
  968. }
  969. return new DBLockingProvider(
  970. $c->get(IDBConnection::class),
  971. $c->get(ILogger::class),
  972. new TimeFactory(),
  973. $ttl,
  974. !\OC::$CLI
  975. );
  976. }
  977. return new NoopLockingProvider();
  978. });
  979. /** @deprecated 19.0.0 */
  980. $this->registerDeprecatedAlias('LockingProvider', ILockingProvider::class);
  981. $this->registerAlias(IMountManager::class, \OC\Files\Mount\Manager::class);
  982. /** @deprecated 19.0.0 */
  983. $this->registerDeprecatedAlias('MountManager', IMountManager::class);
  984. $this->registerService(IMimeTypeDetector::class, function (ContainerInterface $c) {
  985. return new \OC\Files\Type\Detection(
  986. $c->get(IURLGenerator::class),
  987. $c->get(ILogger::class),
  988. \OC::$configDir,
  989. \OC::$SERVERROOT . '/resources/config/'
  990. );
  991. });
  992. /** @deprecated 19.0.0 */
  993. $this->registerDeprecatedAlias('MimeTypeDetector', IMimeTypeDetector::class);
  994. $this->registerAlias(IMimeTypeLoader::class, Loader::class);
  995. /** @deprecated 19.0.0 */
  996. $this->registerDeprecatedAlias('MimeTypeLoader', IMimeTypeLoader::class);
  997. $this->registerService(BundleFetcher::class, function () {
  998. return new BundleFetcher($this->getL10N('lib'));
  999. });
  1000. $this->registerAlias(\OCP\Notification\IManager::class, Manager::class);
  1001. /** @deprecated 19.0.0 */
  1002. $this->registerDeprecatedAlias('NotificationManager', \OCP\Notification\IManager::class);
  1003. $this->registerService(CapabilitiesManager::class, function (ContainerInterface $c) {
  1004. $manager = new CapabilitiesManager($c->get(LoggerInterface::class));
  1005. $manager->registerCapability(function () use ($c) {
  1006. return new \OC\OCS\CoreCapabilities($c->get(\OCP\IConfig::class));
  1007. });
  1008. $manager->registerCapability(function () use ($c) {
  1009. return $c->get(\OC\Security\Bruteforce\Capabilities::class);
  1010. });
  1011. return $manager;
  1012. });
  1013. /** @deprecated 19.0.0 */
  1014. $this->registerDeprecatedAlias('CapabilitiesManager', CapabilitiesManager::class);
  1015. $this->registerService(ICommentsManager::class, function (Server $c) {
  1016. $config = $c->get(\OCP\IConfig::class);
  1017. $factoryClass = $config->getSystemValue('comments.managerFactory', CommentsManagerFactory::class);
  1018. /** @var \OCP\Comments\ICommentsManagerFactory $factory */
  1019. $factory = new $factoryClass($this);
  1020. $manager = $factory->getManager();
  1021. $manager->registerDisplayNameResolver('user', function ($id) use ($c) {
  1022. $manager = $c->get(IUserManager::class);
  1023. $user = $manager->get($id);
  1024. if (is_null($user)) {
  1025. $l = $c->getL10N('core');
  1026. $displayName = $l->t('Unknown user');
  1027. } else {
  1028. $displayName = $user->getDisplayName();
  1029. }
  1030. return $displayName;
  1031. });
  1032. return $manager;
  1033. });
  1034. /** @deprecated 19.0.0 */
  1035. $this->registerDeprecatedAlias('CommentsManager', ICommentsManager::class);
  1036. $this->registerAlias(\OC_Defaults::class, 'ThemingDefaults');
  1037. $this->registerService('ThemingDefaults', function (Server $c) {
  1038. /*
  1039. * Dark magic for autoloader.
  1040. * If we do a class_exists it will try to load the class which will
  1041. * make composer cache the result. Resulting in errors when enabling
  1042. * the theming app.
  1043. */
  1044. $prefixes = \OC::$composerAutoloader->getPrefixesPsr4();
  1045. if (isset($prefixes['OCA\\Theming\\'])) {
  1046. $classExists = true;
  1047. } else {
  1048. $classExists = false;
  1049. }
  1050. if ($classExists && $c->get(\OCP\IConfig::class)->getSystemValue('installed', false) && $c->get(IAppManager::class)->isInstalled('theming') && $c->getTrustedDomainHelper()->isTrustedDomain($c->getRequest()->getInsecureServerHost())) {
  1051. return new ThemingDefaults(
  1052. $c->get(\OCP\IConfig::class),
  1053. $c->getL10N('theming'),
  1054. $c->get(IURLGenerator::class),
  1055. $c->get(ICacheFactory::class),
  1056. new Util($c->get(\OCP\IConfig::class), $this->get(IAppManager::class), $c->getAppDataDir('theming')),
  1057. new ImageManager(
  1058. $c->get(\OCP\IConfig::class),
  1059. $c->getAppDataDir('theming'),
  1060. $c->get(IURLGenerator::class),
  1061. $this->get(ICacheFactory::class),
  1062. $this->get(ILogger::class),
  1063. $this->get(ITempManager::class)
  1064. ),
  1065. $c->get(IAppManager::class),
  1066. $c->get(INavigationManager::class)
  1067. );
  1068. }
  1069. return new \OC_Defaults();
  1070. });
  1071. $this->registerService(JSCombiner::class, function (Server $c) {
  1072. return new JSCombiner(
  1073. $c->getAppDataDir('js'),
  1074. $c->get(IURLGenerator::class),
  1075. $this->get(ICacheFactory::class),
  1076. $c->get(SystemConfig::class),
  1077. $c->get(ILogger::class)
  1078. );
  1079. });
  1080. $this->registerAlias(\OCP\EventDispatcher\IEventDispatcher::class, \OC\EventDispatcher\EventDispatcher::class);
  1081. /** @deprecated 19.0.0 */
  1082. $this->registerDeprecatedAlias('EventDispatcher', \OC\EventDispatcher\SymfonyAdapter::class);
  1083. $this->registerAlias(EventDispatcherInterface::class, \OC\EventDispatcher\SymfonyAdapter::class);
  1084. $this->registerService('CryptoWrapper', function (ContainerInterface $c) {
  1085. // FIXME: Instantiiated here due to cyclic dependency
  1086. $request = new Request(
  1087. [
  1088. 'get' => $_GET,
  1089. 'post' => $_POST,
  1090. 'files' => $_FILES,
  1091. 'server' => $_SERVER,
  1092. 'env' => $_ENV,
  1093. 'cookies' => $_COOKIE,
  1094. 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD']))
  1095. ? $_SERVER['REQUEST_METHOD']
  1096. : null,
  1097. ],
  1098. $c->get(ISecureRandom::class),
  1099. $c->get(\OCP\IConfig::class)
  1100. );
  1101. return new CryptoWrapper(
  1102. $c->get(\OCP\IConfig::class),
  1103. $c->get(ICrypto::class),
  1104. $c->get(ISecureRandom::class),
  1105. $request
  1106. );
  1107. });
  1108. /** @deprecated 19.0.0 */
  1109. $this->registerDeprecatedAlias('CsrfTokenManager', CsrfTokenManager::class);
  1110. $this->registerService(SessionStorage::class, function (ContainerInterface $c) {
  1111. return new SessionStorage($c->get(ISession::class));
  1112. });
  1113. $this->registerAlias(\OCP\Security\IContentSecurityPolicyManager::class, ContentSecurityPolicyManager::class);
  1114. /** @deprecated 19.0.0 */
  1115. $this->registerDeprecatedAlias('ContentSecurityPolicyManager', ContentSecurityPolicyManager::class);
  1116. $this->registerService(\OCP\Share\IManager::class, function (IServerContainer $c) {
  1117. $config = $c->get(\OCP\IConfig::class);
  1118. $factoryClass = $config->getSystemValue('sharing.managerFactory', ProviderFactory::class);
  1119. /** @var \OCP\Share\IProviderFactory $factory */
  1120. $factory = new $factoryClass($this);
  1121. $manager = new \OC\Share20\Manager(
  1122. $c->get(ILogger::class),
  1123. $c->get(\OCP\IConfig::class),
  1124. $c->get(ISecureRandom::class),
  1125. $c->get(IHasher::class),
  1126. $c->get(IMountManager::class),
  1127. $c->get(IGroupManager::class),
  1128. $c->getL10N('lib'),
  1129. $c->get(IFactory::class),
  1130. $factory,
  1131. $c->get(IUserManager::class),
  1132. $c->get(IRootFolder::class),
  1133. $c->get(SymfonyAdapter::class),
  1134. $c->get(IMailer::class),
  1135. $c->get(IURLGenerator::class),
  1136. $c->get('ThemingDefaults'),
  1137. $c->get(IEventDispatcher::class),
  1138. $c->get(IUserSession::class)
  1139. );
  1140. return $manager;
  1141. });
  1142. /** @deprecated 19.0.0 */
  1143. $this->registerDeprecatedAlias('ShareManager', \OCP\Share\IManager::class);
  1144. $this->registerService(\OCP\Collaboration\Collaborators\ISearch::class, function (Server $c) {
  1145. $instance = new Collaboration\Collaborators\Search($c);
  1146. // register default plugins
  1147. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_USER', 'class' => UserPlugin::class]);
  1148. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_GROUP', 'class' => GroupPlugin::class]);
  1149. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_EMAIL', 'class' => MailPlugin::class]);
  1150. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE', 'class' => RemotePlugin::class]);
  1151. $instance->registerPlugin(['shareType' => 'SHARE_TYPE_REMOTE_GROUP', 'class' => RemoteGroupPlugin::class]);
  1152. return $instance;
  1153. });
  1154. /** @deprecated 19.0.0 */
  1155. $this->registerDeprecatedAlias('CollaboratorSearch', \OCP\Collaboration\Collaborators\ISearch::class);
  1156. $this->registerAlias(\OCP\Collaboration\Collaborators\ISearchResult::class, \OC\Collaboration\Collaborators\SearchResult::class);
  1157. $this->registerAlias(\OCP\Collaboration\AutoComplete\IManager::class, \OC\Collaboration\AutoComplete\Manager::class);
  1158. $this->registerAlias(\OCP\Collaboration\Resources\IProviderManager::class, \OC\Collaboration\Resources\ProviderManager::class);
  1159. $this->registerAlias(\OCP\Collaboration\Resources\IManager::class, \OC\Collaboration\Resources\Manager::class);
  1160. $this->registerDeprecatedAlias('SettingsManager', \OC\Settings\Manager::class);
  1161. $this->registerAlias(\OCP\Settings\IManager::class, \OC\Settings\Manager::class);
  1162. $this->registerService(\OC\Files\AppData\Factory::class, function (ContainerInterface $c) {
  1163. return new \OC\Files\AppData\Factory(
  1164. $c->get(IRootFolder::class),
  1165. $c->get(SystemConfig::class)
  1166. );
  1167. });
  1168. $this->registerService('LockdownManager', function (ContainerInterface $c) {
  1169. return new LockdownManager(function () use ($c) {
  1170. return $c->get(ISession::class);
  1171. });
  1172. });
  1173. $this->registerService(\OCP\OCS\IDiscoveryService::class, function (ContainerInterface $c) {
  1174. return new DiscoveryService(
  1175. $c->get(ICacheFactory::class),
  1176. $c->get(IClientService::class)
  1177. );
  1178. });
  1179. $this->registerService(ICloudIdManager::class, function (ContainerInterface $c) {
  1180. return new CloudIdManager($c->get(\OCP\Contacts\IManager::class), $c->get(IURLGenerator::class), $c->get(IUserManager::class));
  1181. });
  1182. $this->registerAlias(\OCP\GlobalScale\IConfig::class, \OC\GlobalScale\Config::class);
  1183. $this->registerService(ICloudFederationProviderManager::class, function (ContainerInterface $c) {
  1184. return new CloudFederationProviderManager(
  1185. $c->get(IAppManager::class),
  1186. $c->get(IClientService::class),
  1187. $c->get(ICloudIdManager::class),
  1188. $c->get(ILogger::class)
  1189. );
  1190. });
  1191. $this->registerService(ICloudFederationFactory::class, function (Server $c) {
  1192. return new CloudFederationFactory();
  1193. });
  1194. $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class);
  1195. /** @deprecated 19.0.0 */
  1196. $this->registerDeprecatedAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class);
  1197. $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class);
  1198. /** @deprecated 19.0.0 */
  1199. $this->registerDeprecatedAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class);
  1200. $this->registerService(Defaults::class, function (Server $c) {
  1201. return new Defaults(
  1202. $c->getThemingDefaults()
  1203. );
  1204. });
  1205. /** @deprecated 19.0.0 */
  1206. $this->registerDeprecatedAlias('Defaults', \OCP\Defaults::class);
  1207. $this->registerService(\OCP\ISession::class, function (ContainerInterface $c) {
  1208. return $c->get(\OCP\IUserSession::class)->getSession();
  1209. }, false);
  1210. $this->registerService(IShareHelper::class, function (ContainerInterface $c) {
  1211. return new ShareHelper(
  1212. $c->get(\OCP\Share\IManager::class)
  1213. );
  1214. });
  1215. $this->registerService(Installer::class, function (ContainerInterface $c) {
  1216. return new Installer(
  1217. $c->get(AppFetcher::class),
  1218. $c->get(IClientService::class),
  1219. $c->get(ITempManager::class),
  1220. $c->get(LoggerInterface::class),
  1221. $c->get(\OCP\IConfig::class),
  1222. \OC::$CLI
  1223. );
  1224. });
  1225. $this->registerService(IApiFactory::class, function (ContainerInterface $c) {
  1226. return new ApiFactory($c->get(IClientService::class));
  1227. });
  1228. $this->registerService(IInstanceFactory::class, function (ContainerInterface $c) {
  1229. $memcacheFactory = $c->get(ICacheFactory::class);
  1230. return new InstanceFactory($memcacheFactory->createLocal('remoteinstance.'), $c->get(IClientService::class));
  1231. });
  1232. $this->registerAlias(IContactsStore::class, ContactsStore::class);
  1233. $this->registerAlias(IAccountManager::class, AccountManager::class);
  1234. $this->registerAlias(IStorageFactory::class, StorageFactory::class);
  1235. $this->registerAlias(IDashboardManager::class, DashboardManager::class);
  1236. $this->registerAlias(\OCP\Dashboard\IManager::class, \OC\Dashboard\Manager::class);
  1237. $this->registerAlias(IFullTextSearchManager::class, FullTextSearchManager::class);
  1238. $this->registerAlias(ISubAdmin::class, SubAdmin::class);
  1239. $this->registerAlias(IInitialStateService::class, InitialStateService::class);
  1240. $this->registerAlias(\OCP\UserStatus\IManager::class, \OC\UserStatus\Manager::class);
  1241. $this->connectDispatcher();
  1242. }
  1243. public function boot() {
  1244. /** @var HookConnector $hookConnector */
  1245. $hookConnector = $this->get(HookConnector::class);
  1246. $hookConnector->viewToNode();
  1247. }
  1248. /**
  1249. * @return \OCP\Calendar\IManager
  1250. * @deprecated 20.0.0
  1251. */
  1252. public function getCalendarManager() {
  1253. return $this->get(\OC\Calendar\Manager::class);
  1254. }
  1255. /**
  1256. * @return \OCP\Calendar\Resource\IManager
  1257. * @deprecated 20.0.0
  1258. */
  1259. public function getCalendarResourceBackendManager() {
  1260. return $this->get(\OC\Calendar\Resource\Manager::class);
  1261. }
  1262. /**
  1263. * @return \OCP\Calendar\Room\IManager
  1264. * @deprecated 20.0.0
  1265. */
  1266. public function getCalendarRoomBackendManager() {
  1267. return $this->get(\OC\Calendar\Room\Manager::class);
  1268. }
  1269. private function connectDispatcher() {
  1270. $dispatcher = $this->get(SymfonyAdapter::class);
  1271. // Delete avatar on user deletion
  1272. $dispatcher->addListener('OCP\IUser::preDelete', function (GenericEvent $e) {
  1273. $logger = $this->get(ILogger::class);
  1274. $manager = $this->getAvatarManager();
  1275. /** @var IUser $user */
  1276. $user = $e->getSubject();
  1277. try {
  1278. $avatar = $manager->getAvatar($user->getUID());
  1279. $avatar->remove();
  1280. } catch (NotFoundException $e) {
  1281. // no avatar to remove
  1282. } catch (\Exception $e) {
  1283. // Ignore exceptions
  1284. $logger->info('Could not cleanup avatar of ' . $user->getUID());
  1285. }
  1286. });
  1287. $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
  1288. $manager = $this->getAvatarManager();
  1289. /** @var IUser $user */
  1290. $user = $e->getSubject();
  1291. $feature = $e->getArgument('feature');
  1292. $oldValue = $e->getArgument('oldValue');
  1293. $value = $e->getArgument('value');
  1294. // We only change the avatar on display name changes
  1295. if ($feature !== 'displayName') {
  1296. return;
  1297. }
  1298. try {
  1299. $avatar = $manager->getAvatar($user->getUID());
  1300. $avatar->userChanged($feature, $oldValue, $value);
  1301. } catch (NotFoundException $e) {
  1302. // no avatar to remove
  1303. }
  1304. });
  1305. /** @var IEventDispatcher $eventDispatched */
  1306. $eventDispatched = $this->get(IEventDispatcher::class);
  1307. $eventDispatched->addServiceListener(LoginFailed::class, LoginFailedListener::class);
  1308. $eventDispatched->addServiceListener(PostLoginEvent::class, UserLoggedInListener::class);
  1309. }
  1310. /**
  1311. * @return \OCP\Contacts\IManager
  1312. * @deprecated 20.0.0
  1313. */
  1314. public function getContactsManager() {
  1315. return $this->get(\OCP\Contacts\IManager::class);
  1316. }
  1317. /**
  1318. * @return \OC\Encryption\Manager
  1319. * @deprecated 20.0.0
  1320. */
  1321. public function getEncryptionManager() {
  1322. return $this->get(\OCP\Encryption\IManager::class);
  1323. }
  1324. /**
  1325. * @return \OC\Encryption\File
  1326. * @deprecated 20.0.0
  1327. */
  1328. public function getEncryptionFilesHelper() {
  1329. return $this->get(IFile::class);
  1330. }
  1331. /**
  1332. * @return \OCP\Encryption\Keys\IStorage
  1333. * @deprecated 20.0.0
  1334. */
  1335. public function getEncryptionKeyStorage() {
  1336. return $this->get(IStorage::class);
  1337. }
  1338. /**
  1339. * The current request object holding all information about the request
  1340. * currently being processed is returned from this method.
  1341. * In case the current execution was not initiated by a web request null is returned
  1342. *
  1343. * @return \OCP\IRequest
  1344. * @deprecated 20.0.0
  1345. */
  1346. public function getRequest() {
  1347. return $this->get(IRequest::class);
  1348. }
  1349. /**
  1350. * Returns the preview manager which can create preview images for a given file
  1351. *
  1352. * @return IPreview
  1353. * @deprecated 20.0.0
  1354. */
  1355. public function getPreviewManager() {
  1356. return $this->get(IPreview::class);
  1357. }
  1358. /**
  1359. * Returns the tag manager which can get and set tags for different object types
  1360. *
  1361. * @see \OCP\ITagManager::load()
  1362. * @return ITagManager
  1363. * @deprecated 20.0.0
  1364. */
  1365. public function getTagManager() {
  1366. return $this->get(ITagManager::class);
  1367. }
  1368. /**
  1369. * Returns the system-tag manager
  1370. *
  1371. * @return ISystemTagManager
  1372. *
  1373. * @since 9.0.0
  1374. * @deprecated 20.0.0
  1375. */
  1376. public function getSystemTagManager() {
  1377. return $this->get(ISystemTagManager::class);
  1378. }
  1379. /**
  1380. * Returns the system-tag object mapper
  1381. *
  1382. * @return ISystemTagObjectMapper
  1383. *
  1384. * @since 9.0.0
  1385. * @deprecated 20.0.0
  1386. */
  1387. public function getSystemTagObjectMapper() {
  1388. return $this->get(ISystemTagObjectMapper::class);
  1389. }
  1390. /**
  1391. * Returns the avatar manager, used for avatar functionality
  1392. *
  1393. * @return IAvatarManager
  1394. * @deprecated 20.0.0
  1395. */
  1396. public function getAvatarManager() {
  1397. return $this->get(IAvatarManager::class);
  1398. }
  1399. /**
  1400. * Returns the root folder of ownCloud's data directory
  1401. *
  1402. * @return IRootFolder
  1403. * @deprecated 20.0.0
  1404. */
  1405. public function getRootFolder() {
  1406. return $this->get(IRootFolder::class);
  1407. }
  1408. /**
  1409. * Returns the root folder of ownCloud's data directory
  1410. * This is the lazy variant so this gets only initialized once it
  1411. * is actually used.
  1412. *
  1413. * @return IRootFolder
  1414. * @deprecated 20.0.0
  1415. */
  1416. public function getLazyRootFolder() {
  1417. return $this->get(IRootFolder::class);
  1418. }
  1419. /**
  1420. * Returns a view to ownCloud's files folder
  1421. *
  1422. * @param string $userId user ID
  1423. * @return \OCP\Files\Folder|null
  1424. * @deprecated 20.0.0
  1425. */
  1426. public function getUserFolder($userId = null) {
  1427. if ($userId === null) {
  1428. $user = $this->get(IUserSession::class)->getUser();
  1429. if (!$user) {
  1430. return null;
  1431. }
  1432. $userId = $user->getUID();
  1433. }
  1434. $root = $this->get(IRootFolder::class);
  1435. return $root->getUserFolder($userId);
  1436. }
  1437. /**
  1438. * @return \OC\User\Manager
  1439. * @deprecated 20.0.0
  1440. */
  1441. public function getUserManager() {
  1442. return $this->get(IUserManager::class);
  1443. }
  1444. /**
  1445. * @return \OC\Group\Manager
  1446. * @deprecated 20.0.0
  1447. */
  1448. public function getGroupManager() {
  1449. return $this->get(IGroupManager::class);
  1450. }
  1451. /**
  1452. * @return \OC\User\Session
  1453. * @deprecated 20.0.0
  1454. */
  1455. public function getUserSession() {
  1456. return $this->get(IUserSession::class);
  1457. }
  1458. /**
  1459. * @return \OCP\ISession
  1460. * @deprecated 20.0.0
  1461. */
  1462. public function getSession() {
  1463. return $this->get(IUserSession::class)->getSession();
  1464. }
  1465. /**
  1466. * @param \OCP\ISession $session
  1467. */
  1468. public function setSession(\OCP\ISession $session) {
  1469. $this->get(SessionStorage::class)->setSession($session);
  1470. $this->get(IUserSession::class)->setSession($session);
  1471. $this->get(Store::class)->setSession($session);
  1472. }
  1473. /**
  1474. * @return \OC\Authentication\TwoFactorAuth\Manager
  1475. * @deprecated 20.0.0
  1476. */
  1477. public function getTwoFactorAuthManager() {
  1478. return $this->get(\OC\Authentication\TwoFactorAuth\Manager::class);
  1479. }
  1480. /**
  1481. * @return \OC\NavigationManager
  1482. * @deprecated 20.0.0
  1483. */
  1484. public function getNavigationManager() {
  1485. return $this->get(INavigationManager::class);
  1486. }
  1487. /**
  1488. * @return \OCP\IConfig
  1489. * @deprecated 20.0.0
  1490. */
  1491. public function getConfig() {
  1492. return $this->get(AllConfig::class);
  1493. }
  1494. /**
  1495. * @return \OC\SystemConfig
  1496. * @deprecated 20.0.0
  1497. */
  1498. public function getSystemConfig() {
  1499. return $this->get(SystemConfig::class);
  1500. }
  1501. /**
  1502. * Returns the app config manager
  1503. *
  1504. * @return IAppConfig
  1505. * @deprecated 20.0.0
  1506. */
  1507. public function getAppConfig() {
  1508. return $this->get(IAppConfig::class);
  1509. }
  1510. /**
  1511. * @return IFactory
  1512. * @deprecated 20.0.0
  1513. */
  1514. public function getL10NFactory() {
  1515. return $this->get(IFactory::class);
  1516. }
  1517. /**
  1518. * get an L10N instance
  1519. *
  1520. * @param string $app appid
  1521. * @param string $lang
  1522. * @return IL10N
  1523. * @deprecated 20.0.0
  1524. */
  1525. public function getL10N($app, $lang = null) {
  1526. return $this->get(IFactory::class)->get($app, $lang);
  1527. }
  1528. /**
  1529. * @return IURLGenerator
  1530. * @deprecated 20.0.0
  1531. */
  1532. public function getURLGenerator() {
  1533. return $this->get(IURLGenerator::class);
  1534. }
  1535. /**
  1536. * @return AppFetcher
  1537. * @deprecated 20.0.0
  1538. */
  1539. public function getAppFetcher() {
  1540. return $this->get(AppFetcher::class);
  1541. }
  1542. /**
  1543. * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use
  1544. * getMemCacheFactory() instead.
  1545. *
  1546. * @return ICache
  1547. * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache
  1548. */
  1549. public function getCache() {
  1550. return $this->get(ICache::class);
  1551. }
  1552. /**
  1553. * Returns an \OCP\CacheFactory instance
  1554. *
  1555. * @return \OCP\ICacheFactory
  1556. * @deprecated 20.0.0
  1557. */
  1558. public function getMemCacheFactory() {
  1559. return $this->get(ICacheFactory::class);
  1560. }
  1561. /**
  1562. * Returns an \OC\RedisFactory instance
  1563. *
  1564. * @return \OC\RedisFactory
  1565. * @deprecated 20.0.0
  1566. */
  1567. public function getGetRedisFactory() {
  1568. return $this->get('RedisFactory');
  1569. }
  1570. /**
  1571. * Returns the current session
  1572. *
  1573. * @return \OCP\IDBConnection
  1574. * @deprecated 20.0.0
  1575. */
  1576. public function getDatabaseConnection() {
  1577. return $this->get(IDBConnection::class);
  1578. }
  1579. /**
  1580. * Returns the activity manager
  1581. *
  1582. * @return \OCP\Activity\IManager
  1583. * @deprecated 20.0.0
  1584. */
  1585. public function getActivityManager() {
  1586. return $this->get(\OCP\Activity\IManager::class);
  1587. }
  1588. /**
  1589. * Returns an job list for controlling background jobs
  1590. *
  1591. * @return IJobList
  1592. * @deprecated 20.0.0
  1593. */
  1594. public function getJobList() {
  1595. return $this->get(IJobList::class);
  1596. }
  1597. /**
  1598. * Returns a logger instance
  1599. *
  1600. * @return ILogger
  1601. * @deprecated 20.0.0
  1602. */
  1603. public function getLogger() {
  1604. return $this->get(ILogger::class);
  1605. }
  1606. /**
  1607. * @return ILogFactory
  1608. * @throws \OCP\AppFramework\QueryException
  1609. * @deprecated 20.0.0
  1610. */
  1611. public function getLogFactory() {
  1612. return $this->get(ILogFactory::class);
  1613. }
  1614. /**
  1615. * Returns a router for generating and matching urls
  1616. *
  1617. * @return IRouter
  1618. * @deprecated 20.0.0
  1619. */
  1620. public function getRouter() {
  1621. return $this->get(IRouter::class);
  1622. }
  1623. /**
  1624. * Returns a search instance
  1625. *
  1626. * @return ISearch
  1627. * @deprecated 20.0.0
  1628. */
  1629. public function getSearch() {
  1630. return $this->get(ISearch::class);
  1631. }
  1632. /**
  1633. * Returns a SecureRandom instance
  1634. *
  1635. * @return \OCP\Security\ISecureRandom
  1636. * @deprecated 20.0.0
  1637. */
  1638. public function getSecureRandom() {
  1639. return $this->get(ISecureRandom::class);
  1640. }
  1641. /**
  1642. * Returns a Crypto instance
  1643. *
  1644. * @return ICrypto
  1645. * @deprecated 20.0.0
  1646. */
  1647. public function getCrypto() {
  1648. return $this->get(ICrypto::class);
  1649. }
  1650. /**
  1651. * Returns a Hasher instance
  1652. *
  1653. * @return IHasher
  1654. * @deprecated 20.0.0
  1655. */
  1656. public function getHasher() {
  1657. return $this->get(IHasher::class);
  1658. }
  1659. /**
  1660. * Returns a CredentialsManager instance
  1661. *
  1662. * @return ICredentialsManager
  1663. * @deprecated 20.0.0
  1664. */
  1665. public function getCredentialsManager() {
  1666. return $this->get(ICredentialsManager::class);
  1667. }
  1668. /**
  1669. * Get the certificate manager
  1670. *
  1671. * @return \OCP\ICertificateManager
  1672. */
  1673. public function getCertificateManager() {
  1674. return $this->get(ICertificateManager::class);
  1675. }
  1676. /**
  1677. * Returns an instance of the HTTP client service
  1678. *
  1679. * @return IClientService
  1680. * @deprecated 20.0.0
  1681. */
  1682. public function getHTTPClientService() {
  1683. return $this->get(IClientService::class);
  1684. }
  1685. /**
  1686. * Create a new event source
  1687. *
  1688. * @return \OCP\IEventSource
  1689. * @deprecated 20.0.0
  1690. */
  1691. public function createEventSource() {
  1692. return new \OC_EventSource();
  1693. }
  1694. /**
  1695. * Get the active event logger
  1696. *
  1697. * The returned logger only logs data when debug mode is enabled
  1698. *
  1699. * @return IEventLogger
  1700. * @deprecated 20.0.0
  1701. */
  1702. public function getEventLogger() {
  1703. return $this->get(IEventLogger::class);
  1704. }
  1705. /**
  1706. * Get the active query logger
  1707. *
  1708. * The returned logger only logs data when debug mode is enabled
  1709. *
  1710. * @return IQueryLogger
  1711. * @deprecated 20.0.0
  1712. */
  1713. public function getQueryLogger() {
  1714. return $this->get(IQueryLogger::class);
  1715. }
  1716. /**
  1717. * Get the manager for temporary files and folders
  1718. *
  1719. * @return \OCP\ITempManager
  1720. * @deprecated 20.0.0
  1721. */
  1722. public function getTempManager() {
  1723. return $this->get(ITempManager::class);
  1724. }
  1725. /**
  1726. * Get the app manager
  1727. *
  1728. * @return \OCP\App\IAppManager
  1729. * @deprecated 20.0.0
  1730. */
  1731. public function getAppManager() {
  1732. return $this->get(IAppManager::class);
  1733. }
  1734. /**
  1735. * Creates a new mailer
  1736. *
  1737. * @return IMailer
  1738. * @deprecated 20.0.0
  1739. */
  1740. public function getMailer() {
  1741. return $this->get(IMailer::class);
  1742. }
  1743. /**
  1744. * Get the webroot
  1745. *
  1746. * @return string
  1747. * @deprecated 20.0.0
  1748. */
  1749. public function getWebRoot() {
  1750. return $this->webRoot;
  1751. }
  1752. /**
  1753. * @return \OC\OCSClient
  1754. * @deprecated 20.0.0
  1755. */
  1756. public function getOcsClient() {
  1757. return $this->get('OcsClient');
  1758. }
  1759. /**
  1760. * @return IDateTimeZone
  1761. * @deprecated 20.0.0
  1762. */
  1763. public function getDateTimeZone() {
  1764. return $this->get(IDateTimeZone::class);
  1765. }
  1766. /**
  1767. * @return IDateTimeFormatter
  1768. * @deprecated 20.0.0
  1769. */
  1770. public function getDateTimeFormatter() {
  1771. return $this->get(IDateTimeFormatter::class);
  1772. }
  1773. /**
  1774. * @return IMountProviderCollection
  1775. * @deprecated 20.0.0
  1776. */
  1777. public function getMountProviderCollection() {
  1778. return $this->get(IMountProviderCollection::class);
  1779. }
  1780. /**
  1781. * Get the IniWrapper
  1782. *
  1783. * @return IniGetWrapper
  1784. * @deprecated 20.0.0
  1785. */
  1786. public function getIniWrapper() {
  1787. return $this->get(IniGetWrapper::class);
  1788. }
  1789. /**
  1790. * @return \OCP\Command\IBus
  1791. * @deprecated 20.0.0
  1792. */
  1793. public function getCommandBus() {
  1794. return $this->get(IBus::class);
  1795. }
  1796. /**
  1797. * Get the trusted domain helper
  1798. *
  1799. * @return TrustedDomainHelper
  1800. * @deprecated 20.0.0
  1801. */
  1802. public function getTrustedDomainHelper() {
  1803. return $this->get(TrustedDomainHelper::class);
  1804. }
  1805. /**
  1806. * Get the locking provider
  1807. *
  1808. * @return ILockingProvider
  1809. * @since 8.1.0
  1810. * @deprecated 20.0.0
  1811. */
  1812. public function getLockingProvider() {
  1813. return $this->get(ILockingProvider::class);
  1814. }
  1815. /**
  1816. * @return IMountManager
  1817. * @deprecated 20.0.0
  1818. **/
  1819. public function getMountManager() {
  1820. return $this->get(IMountManager::class);
  1821. }
  1822. /**
  1823. * @return IUserMountCache
  1824. * @deprecated 20.0.0
  1825. */
  1826. public function getUserMountCache() {
  1827. return $this->get(IUserMountCache::class);
  1828. }
  1829. /**
  1830. * Get the MimeTypeDetector
  1831. *
  1832. * @return IMimeTypeDetector
  1833. * @deprecated 20.0.0
  1834. */
  1835. public function getMimeTypeDetector() {
  1836. return $this->get(IMimeTypeDetector::class);
  1837. }
  1838. /**
  1839. * Get the MimeTypeLoader
  1840. *
  1841. * @return IMimeTypeLoader
  1842. * @deprecated 20.0.0
  1843. */
  1844. public function getMimeTypeLoader() {
  1845. return $this->get(IMimeTypeLoader::class);
  1846. }
  1847. /**
  1848. * Get the manager of all the capabilities
  1849. *
  1850. * @return CapabilitiesManager
  1851. * @deprecated 20.0.0
  1852. */
  1853. public function getCapabilitiesManager() {
  1854. return $this->get(CapabilitiesManager::class);
  1855. }
  1856. /**
  1857. * Get the EventDispatcher
  1858. *
  1859. * @return EventDispatcherInterface
  1860. * @since 8.2.0
  1861. * @deprecated 18.0.0 use \OCP\EventDispatcher\IEventDispatcher
  1862. */
  1863. public function getEventDispatcher() {
  1864. return $this->get(\OC\EventDispatcher\SymfonyAdapter::class);
  1865. }
  1866. /**
  1867. * Get the Notification Manager
  1868. *
  1869. * @return \OCP\Notification\IManager
  1870. * @since 8.2.0
  1871. * @deprecated 20.0.0
  1872. */
  1873. public function getNotificationManager() {
  1874. return $this->get(\OCP\Notification\IManager::class);
  1875. }
  1876. /**
  1877. * @return ICommentsManager
  1878. * @deprecated 20.0.0
  1879. */
  1880. public function getCommentsManager() {
  1881. return $this->get(ICommentsManager::class);
  1882. }
  1883. /**
  1884. * @return \OCA\Theming\ThemingDefaults
  1885. * @deprecated 20.0.0
  1886. */
  1887. public function getThemingDefaults() {
  1888. return $this->get('ThemingDefaults');
  1889. }
  1890. /**
  1891. * @return \OC\IntegrityCheck\Checker
  1892. * @deprecated 20.0.0
  1893. */
  1894. public function getIntegrityCodeChecker() {
  1895. return $this->get('IntegrityCodeChecker');
  1896. }
  1897. /**
  1898. * @return \OC\Session\CryptoWrapper
  1899. * @deprecated 20.0.0
  1900. */
  1901. public function getSessionCryptoWrapper() {
  1902. return $this->get('CryptoWrapper');
  1903. }
  1904. /**
  1905. * @return CsrfTokenManager
  1906. * @deprecated 20.0.0
  1907. */
  1908. public function getCsrfTokenManager() {
  1909. return $this->get(CsrfTokenManager::class);
  1910. }
  1911. /**
  1912. * @return Throttler
  1913. * @deprecated 20.0.0
  1914. */
  1915. public function getBruteForceThrottler() {
  1916. return $this->get(Throttler::class);
  1917. }
  1918. /**
  1919. * @return IContentSecurityPolicyManager
  1920. * @deprecated 20.0.0
  1921. */
  1922. public function getContentSecurityPolicyManager() {
  1923. return $this->get(ContentSecurityPolicyManager::class);
  1924. }
  1925. /**
  1926. * @return ContentSecurityPolicyNonceManager
  1927. * @deprecated 20.0.0
  1928. */
  1929. public function getContentSecurityPolicyNonceManager() {
  1930. return $this->get(ContentSecurityPolicyNonceManager::class);
  1931. }
  1932. /**
  1933. * Not a public API as of 8.2, wait for 9.0
  1934. *
  1935. * @return \OCA\Files_External\Service\BackendService
  1936. * @deprecated 20.0.0
  1937. */
  1938. public function getStoragesBackendService() {
  1939. return $this->get(BackendService::class);
  1940. }
  1941. /**
  1942. * Not a public API as of 8.2, wait for 9.0
  1943. *
  1944. * @return \OCA\Files_External\Service\GlobalStoragesService
  1945. * @deprecated 20.0.0
  1946. */
  1947. public function getGlobalStoragesService() {
  1948. return $this->get(GlobalStoragesService::class);
  1949. }
  1950. /**
  1951. * Not a public API as of 8.2, wait for 9.0
  1952. *
  1953. * @return \OCA\Files_External\Service\UserGlobalStoragesService
  1954. * @deprecated 20.0.0
  1955. */
  1956. public function getUserGlobalStoragesService() {
  1957. return $this->get(UserGlobalStoragesService::class);
  1958. }
  1959. /**
  1960. * Not a public API as of 8.2, wait for 9.0
  1961. *
  1962. * @return \OCA\Files_External\Service\UserStoragesService
  1963. * @deprecated 20.0.0
  1964. */
  1965. public function getUserStoragesService() {
  1966. return $this->get(UserStoragesService::class);
  1967. }
  1968. /**
  1969. * @return \OCP\Share\IManager
  1970. * @deprecated 20.0.0
  1971. */
  1972. public function getShareManager() {
  1973. return $this->get(\OCP\Share\IManager::class);
  1974. }
  1975. /**
  1976. * @return \OCP\Collaboration\Collaborators\ISearch
  1977. * @deprecated 20.0.0
  1978. */
  1979. public function getCollaboratorSearch() {
  1980. return $this->get(\OCP\Collaboration\Collaborators\ISearch::class);
  1981. }
  1982. /**
  1983. * @return \OCP\Collaboration\AutoComplete\IManager
  1984. * @deprecated 20.0.0
  1985. */
  1986. public function getAutoCompleteManager() {
  1987. return $this->get(IManager::class);
  1988. }
  1989. /**
  1990. * Returns the LDAP Provider
  1991. *
  1992. * @return \OCP\LDAP\ILDAPProvider
  1993. * @deprecated 20.0.0
  1994. */
  1995. public function getLDAPProvider() {
  1996. return $this->get('LDAPProvider');
  1997. }
  1998. /**
  1999. * @return \OCP\Settings\IManager
  2000. * @deprecated 20.0.0
  2001. */
  2002. public function getSettingsManager() {
  2003. return $this->get(\OC\Settings\Manager::class);
  2004. }
  2005. /**
  2006. * @return \OCP\Files\IAppData
  2007. * @deprecated 20.0.0
  2008. */
  2009. public function getAppDataDir($app) {
  2010. /** @var \OC\Files\AppData\Factory $factory */
  2011. $factory = $this->get(\OC\Files\AppData\Factory::class);
  2012. return $factory->get($app);
  2013. }
  2014. /**
  2015. * @return \OCP\Lockdown\ILockdownManager
  2016. * @deprecated 20.0.0
  2017. */
  2018. public function getLockdownManager() {
  2019. return $this->get('LockdownManager');
  2020. }
  2021. /**
  2022. * @return \OCP\Federation\ICloudIdManager
  2023. * @deprecated 20.0.0
  2024. */
  2025. public function getCloudIdManager() {
  2026. return $this->get(ICloudIdManager::class);
  2027. }
  2028. /**
  2029. * @return \OCP\GlobalScale\IConfig
  2030. * @deprecated 20.0.0
  2031. */
  2032. public function getGlobalScaleConfig() {
  2033. return $this->get(IConfig::class);
  2034. }
  2035. /**
  2036. * @return \OCP\Federation\ICloudFederationProviderManager
  2037. * @deprecated 20.0.0
  2038. */
  2039. public function getCloudFederationProviderManager() {
  2040. return $this->get(ICloudFederationProviderManager::class);
  2041. }
  2042. /**
  2043. * @return \OCP\Remote\Api\IApiFactory
  2044. * @deprecated 20.0.0
  2045. */
  2046. public function getRemoteApiFactory() {
  2047. return $this->get(IApiFactory::class);
  2048. }
  2049. /**
  2050. * @return \OCP\Federation\ICloudFederationFactory
  2051. * @deprecated 20.0.0
  2052. */
  2053. public function getCloudFederationFactory() {
  2054. return $this->get(ICloudFederationFactory::class);
  2055. }
  2056. /**
  2057. * @return \OCP\Remote\IInstanceFactory
  2058. * @deprecated 20.0.0
  2059. */
  2060. public function getRemoteInstanceFactory() {
  2061. return $this->get(IInstanceFactory::class);
  2062. }
  2063. /**
  2064. * @return IStorageFactory
  2065. * @deprecated 20.0.0
  2066. */
  2067. public function getStorageFactory() {
  2068. return $this->get(IStorageFactory::class);
  2069. }
  2070. /**
  2071. * Get the Preview GeneratorHelper
  2072. *
  2073. * @return GeneratorHelper
  2074. * @since 17.0.0
  2075. * @deprecated 20.0.0
  2076. */
  2077. public function getGeneratorHelper() {
  2078. return $this->get(\OC\Preview\GeneratorHelper::class);
  2079. }
  2080. private function registerDeprecatedAlias(string $alias, string $target) {
  2081. $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) {
  2082. try {
  2083. /** @var ILogger $logger */
  2084. $logger = $container->get(ILogger::class);
  2085. $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']);
  2086. } catch (ContainerExceptionInterface $e) {
  2087. // Could not get logger. Continue
  2088. }
  2089. return $container->get($target);
  2090. }, false);
  2091. }
  2092. }