Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

Server.php 71KB

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