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 70KB

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