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

Server.php 72KB

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