Server.php 75 KB

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