@@ -30,67 +30,67 @@ |
||
30 | 30 | |
31 | 31 | class Manager { |
32 | 32 | |
33 | - /** @var ContactsStore */ |
|
34 | - private $store; |
|
33 | + /** @var ContactsStore */ |
|
34 | + private $store; |
|
35 | 35 | |
36 | - /** @var ActionProviderStore */ |
|
37 | - private $actionProviderStore; |
|
36 | + /** @var ActionProviderStore */ |
|
37 | + private $actionProviderStore; |
|
38 | 38 | |
39 | - /** @var IAppManager */ |
|
40 | - private $appManager; |
|
39 | + /** @var IAppManager */ |
|
40 | + private $appManager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param ContactsStore $store |
|
44 | - * @param ActionProviderStore $actionProviderStore |
|
45 | - * @param IAppManager $appManager |
|
46 | - */ |
|
47 | - public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) { |
|
48 | - $this->store = $store; |
|
49 | - $this->actionProviderStore = $actionProviderStore; |
|
50 | - $this->appManager = $appManager; |
|
51 | - } |
|
42 | + /** |
|
43 | + * @param ContactsStore $store |
|
44 | + * @param ActionProviderStore $actionProviderStore |
|
45 | + * @param IAppManager $appManager |
|
46 | + */ |
|
47 | + public function __construct(ContactsStore $store, ActionProviderStore $actionProviderStore, IAppManager $appManager) { |
|
48 | + $this->store = $store; |
|
49 | + $this->actionProviderStore = $actionProviderStore; |
|
50 | + $this->appManager = $appManager; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param string $user |
|
55 | - * @param string $filter |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function getEntries(IUser $user, $filter) { |
|
59 | - $entries = $this->store->getContacts($user, $filter); |
|
53 | + /** |
|
54 | + * @param string $user |
|
55 | + * @param string $filter |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function getEntries(IUser $user, $filter) { |
|
59 | + $entries = $this->store->getContacts($user, $filter); |
|
60 | 60 | |
61 | - $sortedEntries = $this->sortEntries($entries); |
|
62 | - $topEntries = array_slice($sortedEntries, 0, 25); |
|
63 | - $this->processEntries($topEntries, $user); |
|
61 | + $sortedEntries = $this->sortEntries($entries); |
|
62 | + $topEntries = array_slice($sortedEntries, 0, 25); |
|
63 | + $this->processEntries($topEntries, $user); |
|
64 | 64 | |
65 | - $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user); |
|
66 | - return [ |
|
67 | - 'contacts' => $topEntries, |
|
68 | - 'contactsAppEnabled' => $contactsEnabled, |
|
69 | - ]; |
|
70 | - } |
|
65 | + $contactsEnabled = $this->appManager->isEnabledForUser('contacts', $user); |
|
66 | + return [ |
|
67 | + 'contacts' => $topEntries, |
|
68 | + 'contactsAppEnabled' => $contactsEnabled, |
|
69 | + ]; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @param IEntry[] $entries |
|
74 | - * @return IEntry[] |
|
75 | - */ |
|
76 | - private function sortEntries(array $entries) { |
|
77 | - usort($entries, function(IEntry $entryA, IEntry $entryB) { |
|
78 | - return strcasecmp($entryA->getFullName(), $entryB->getFullName()); |
|
79 | - }); |
|
80 | - return $entries; |
|
81 | - } |
|
72 | + /** |
|
73 | + * @param IEntry[] $entries |
|
74 | + * @return IEntry[] |
|
75 | + */ |
|
76 | + private function sortEntries(array $entries) { |
|
77 | + usort($entries, function(IEntry $entryA, IEntry $entryB) { |
|
78 | + return strcasecmp($entryA->getFullName(), $entryB->getFullName()); |
|
79 | + }); |
|
80 | + return $entries; |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * @param IEntry[] $entries |
|
85 | - * @param IUser $user |
|
86 | - */ |
|
87 | - private function processEntries(array $entries, IUser $user) { |
|
88 | - $providers = $this->actionProviderStore->getProviders($user); |
|
89 | - foreach ($entries as $entry) { |
|
90 | - foreach ($providers as $provider) { |
|
91 | - $provider->process($entry); |
|
92 | - } |
|
93 | - } |
|
94 | - } |
|
83 | + /** |
|
84 | + * @param IEntry[] $entries |
|
85 | + * @param IUser $user |
|
86 | + */ |
|
87 | + private function processEntries(array $entries, IUser $user) { |
|
88 | + $providers = $this->actionProviderStore->getProviders($user); |
|
89 | + foreach ($entries as $entry) { |
|
90 | + foreach ($providers as $provider) { |
|
91 | + $provider->process($entry); |
|
92 | + } |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | 96 | } |
@@ -30,66 +30,66 @@ |
||
30 | 30 | |
31 | 31 | class ContactsStore { |
32 | 32 | |
33 | - /** @var IManager */ |
|
34 | - private $contactsManager; |
|
35 | - |
|
36 | - /** |
|
37 | - * @param IManager $contactsManager |
|
38 | - */ |
|
39 | - public function __construct(IManager $contactsManager) { |
|
40 | - $this->contactsManager = $contactsManager; |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @param IUser $user |
|
45 | - * @param string|null $filter |
|
46 | - * @return IEntry[] |
|
47 | - */ |
|
48 | - public function getContacts(IUser $user, $filter) { |
|
49 | - $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
50 | - 'FN', |
|
51 | - ]); |
|
52 | - |
|
53 | - $self = $user->getUID(); |
|
54 | - $entries = array_map(function(array $contact) { |
|
55 | - return $this->contactArrayToEntry($contact); |
|
56 | - }, $allContacts); |
|
57 | - return array_filter($entries, function(IEntry $entry) use ($self) { |
|
58 | - return $entry->getProperty('UID') !== $self; |
|
59 | - }); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * @param array $contact |
|
64 | - * @return Entry |
|
65 | - */ |
|
66 | - private function contactArrayToEntry(array $contact) { |
|
67 | - $entry = new Entry(); |
|
68 | - |
|
69 | - if (isset($contact['id'])) { |
|
70 | - $entry->setId($contact['id']); |
|
71 | - } |
|
72 | - |
|
73 | - if (isset($contact['FN'])) { |
|
74 | - $entry->setFullName($contact['FN']); |
|
75 | - } |
|
76 | - |
|
77 | - $avatarPrefix = "VALUE=uri:"; |
|
78 | - if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) { |
|
79 | - $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix))); |
|
80 | - } |
|
81 | - |
|
82 | - if (isset($contact['EMAIL'])) { |
|
83 | - foreach ($contact['EMAIL'] as $email) { |
|
84 | - $entry->addEMailAddress($email); |
|
85 | - } |
|
86 | - } |
|
87 | - |
|
88 | - // Attach all other properties to the entry too because some |
|
89 | - // providers might make use of it. |
|
90 | - $entry->setProperties($contact); |
|
91 | - |
|
92 | - return $entry; |
|
93 | - } |
|
33 | + /** @var IManager */ |
|
34 | + private $contactsManager; |
|
35 | + |
|
36 | + /** |
|
37 | + * @param IManager $contactsManager |
|
38 | + */ |
|
39 | + public function __construct(IManager $contactsManager) { |
|
40 | + $this->contactsManager = $contactsManager; |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @param IUser $user |
|
45 | + * @param string|null $filter |
|
46 | + * @return IEntry[] |
|
47 | + */ |
|
48 | + public function getContacts(IUser $user, $filter) { |
|
49 | + $allContacts = $this->contactsManager->search($filter ?: '', [ |
|
50 | + 'FN', |
|
51 | + ]); |
|
52 | + |
|
53 | + $self = $user->getUID(); |
|
54 | + $entries = array_map(function(array $contact) { |
|
55 | + return $this->contactArrayToEntry($contact); |
|
56 | + }, $allContacts); |
|
57 | + return array_filter($entries, function(IEntry $entry) use ($self) { |
|
58 | + return $entry->getProperty('UID') !== $self; |
|
59 | + }); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * @param array $contact |
|
64 | + * @return Entry |
|
65 | + */ |
|
66 | + private function contactArrayToEntry(array $contact) { |
|
67 | + $entry = new Entry(); |
|
68 | + |
|
69 | + if (isset($contact['id'])) { |
|
70 | + $entry->setId($contact['id']); |
|
71 | + } |
|
72 | + |
|
73 | + if (isset($contact['FN'])) { |
|
74 | + $entry->setFullName($contact['FN']); |
|
75 | + } |
|
76 | + |
|
77 | + $avatarPrefix = "VALUE=uri:"; |
|
78 | + if (isset($contact['PHOTO']) && strpos($contact['PHOTO'], $avatarPrefix) === 0) { |
|
79 | + $entry->setAvatar(substr($contact['PHOTO'], strlen($avatarPrefix))); |
|
80 | + } |
|
81 | + |
|
82 | + if (isset($contact['EMAIL'])) { |
|
83 | + foreach ($contact['EMAIL'] as $email) { |
|
84 | + $entry->addEMailAddress($email); |
|
85 | + } |
|
86 | + } |
|
87 | + |
|
88 | + // Attach all other properties to the entry too because some |
|
89 | + // providers might make use of it. |
|
90 | + $entry->setProperties($contact); |
|
91 | + |
|
92 | + return $entry; |
|
93 | + } |
|
94 | 94 | |
95 | 95 | } |
@@ -31,30 +31,30 @@ |
||
31 | 31 | |
32 | 32 | class EMailProvider implements IProvider { |
33 | 33 | |
34 | - /** @var IActionFactory */ |
|
35 | - private $actionFactory; |
|
36 | - |
|
37 | - /** @var IURLGenerator */ |
|
38 | - private $urlGenerator; |
|
39 | - |
|
40 | - /** |
|
41 | - * @param IActionFactory $actionFactory |
|
42 | - * @param IURLGenerator $urlGenerator |
|
43 | - */ |
|
44 | - public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
45 | - $this->actionFactory = $actionFactory; |
|
46 | - $this->urlGenerator = $urlGenerator; |
|
47 | - } |
|
48 | - |
|
49 | - /** |
|
50 | - * @param IEntry $entry |
|
51 | - */ |
|
52 | - public function process(IEntry $entry) { |
|
53 | - $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
54 | - foreach ($entry->getEMailAddresses() as $address) { |
|
55 | - $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
56 | - $entry->addAction($action); |
|
57 | - } |
|
58 | - } |
|
34 | + /** @var IActionFactory */ |
|
35 | + private $actionFactory; |
|
36 | + |
|
37 | + /** @var IURLGenerator */ |
|
38 | + private $urlGenerator; |
|
39 | + |
|
40 | + /** |
|
41 | + * @param IActionFactory $actionFactory |
|
42 | + * @param IURLGenerator $urlGenerator |
|
43 | + */ |
|
44 | + public function __construct(IActionFactory $actionFactory, IURLGenerator $urlGenerator) { |
|
45 | + $this->actionFactory = $actionFactory; |
|
46 | + $this->urlGenerator = $urlGenerator; |
|
47 | + } |
|
48 | + |
|
49 | + /** |
|
50 | + * @param IEntry $entry |
|
51 | + */ |
|
52 | + public function process(IEntry $entry) { |
|
53 | + $iconUrl = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'actions/mail.svg')); |
|
54 | + foreach ($entry->getEMailAddresses() as $address) { |
|
55 | + $action = $this->actionFactory->newEMailAction($iconUrl, $address, $address); |
|
56 | + $entry->addAction($action); |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
@@ -44,331 +44,331 @@ |
||
44 | 44 | */ |
45 | 45 | class OC_Template extends \OC\Template\Base { |
46 | 46 | |
47 | - /** @var string */ |
|
48 | - private $renderAs; // Create a full page? |
|
49 | - |
|
50 | - /** @var string */ |
|
51 | - private $path; // The path to the template |
|
52 | - |
|
53 | - /** @var array */ |
|
54 | - private $headers = array(); //custom headers |
|
55 | - |
|
56 | - /** @var string */ |
|
57 | - protected $app; // app id |
|
58 | - |
|
59 | - protected static $initTemplateEngineFirstRun = true; |
|
60 | - |
|
61 | - /** |
|
62 | - * Constructor |
|
63 | - * |
|
64 | - * @param string $app app providing the template |
|
65 | - * @param string $name of the template file (without suffix) |
|
66 | - * @param string $renderAs If $renderAs is set, OC_Template will try to |
|
67 | - * produce a full page in the according layout. For |
|
68 | - * now, $renderAs can be set to "guest", "user" or |
|
69 | - * "admin". |
|
70 | - * @param bool $registerCall = true |
|
71 | - */ |
|
72 | - public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
73 | - // Read the selected theme from the config file |
|
74 | - self::initTemplateEngine($renderAs); |
|
75 | - |
|
76 | - $theme = OC_Util::getTheme(); |
|
77 | - |
|
78 | - $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : ''; |
|
79 | - |
|
80 | - $parts = explode('/', $app); // fix translation when app is something like core/lostpassword |
|
81 | - $l10n = \OC::$server->getL10N($parts[0]); |
|
82 | - /** @var \OCP\Defaults $themeDefaults */ |
|
83 | - $themeDefaults = \OC::$server->query(\OCP\Defaults::class); |
|
84 | - |
|
85 | - list($path, $template) = $this->findTemplate($theme, $app, $name); |
|
86 | - |
|
87 | - // Set the private data |
|
88 | - $this->renderAs = $renderAs; |
|
89 | - $this->path = $path; |
|
90 | - $this->app = $app; |
|
91 | - |
|
92 | - parent::__construct($template, $requestToken, $l10n, $themeDefaults); |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * @param string $renderAs |
|
97 | - */ |
|
98 | - public static function initTemplateEngine($renderAs) { |
|
99 | - if (self::$initTemplateEngineFirstRun){ |
|
100 | - |
|
101 | - //apps that started before the template initialization can load their own scripts/styles |
|
102 | - //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
|
103 | - //meaning the last script/style in this list will be loaded first |
|
104 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
105 | - if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
106 | - OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
111 | - OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
112 | - OC_Util::addStyle('server', null, true); |
|
113 | - OC_Util::addVendorStyle('select2/select2', null, true); |
|
114 | - OC_Util::addStyle('jquery.ocdialog'); |
|
115 | - OC_Util::addTranslations("core", null, true); |
|
116 | - OC_Util::addScript('search', 'search', true); |
|
117 | - OC_Util::addScript('merged-template-prepend', null, true); |
|
118 | - OC_Util::addScript('jquery-ui-fixes'); |
|
119 | - OC_Util::addScript('files/fileinfo'); |
|
120 | - OC_Util::addScript('files/client'); |
|
121 | - OC_Util::addScript('contactsmenu'); |
|
122 | - |
|
123 | - if (\OC::$server->getConfig()->getSystemValue('debug')) { |
|
124 | - // Add the stuff we need always |
|
125 | - // following logic will import all vendor libraries that are |
|
126 | - // specified in core/js/core.json |
|
127 | - $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
128 | - if($fileContent !== false) { |
|
129 | - $coreDependencies = json_decode($fileContent, true); |
|
130 | - foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
131 | - //remove trailing ".js" as addVendorScript will append it |
|
132 | - OC_Util::addVendorScript( |
|
133 | - substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true); |
|
134 | - } |
|
135 | - } else { |
|
136 | - throw new \Exception('Cannot read core/js/core.json'); |
|
137 | - } |
|
138 | - } else { |
|
139 | - // Import all (combined) default vendor libraries |
|
140 | - OC_Util::addVendorScript('core', null, true); |
|
141 | - } |
|
142 | - |
|
143 | - if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) { |
|
144 | - // polyfill for btoa/atob for IE friends |
|
145 | - OC_Util::addVendorScript('base64/base64'); |
|
146 | - // shim for the davclient.js library |
|
147 | - \OCP\Util::addScript('files/iedavclient'); |
|
148 | - } |
|
149 | - |
|
150 | - self::$initTemplateEngineFirstRun = false; |
|
151 | - } |
|
152 | - |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * find the template with the given name |
|
158 | - * @param string $name of the template file (without suffix) |
|
159 | - * |
|
160 | - * Will select the template file for the selected theme. |
|
161 | - * Checking all the possible locations. |
|
162 | - * @param string $theme |
|
163 | - * @param string $app |
|
164 | - * @return string[] |
|
165 | - */ |
|
166 | - protected function findTemplate($theme, $app, $name) { |
|
167 | - // Check if it is a app template or not. |
|
168 | - if( $app !== '' ) { |
|
169 | - $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
|
170 | - } else { |
|
171 | - $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
|
172 | - } |
|
173 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
174 | - $template = $locator->find($name); |
|
175 | - $path = $locator->getPath(); |
|
176 | - return array($path, $template); |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Add a custom element to the header |
|
181 | - * @param string $tag tag name of the element |
|
182 | - * @param array $attributes array of attributes for the element |
|
183 | - * @param string $text the text content for the element. If $text is null then the |
|
184 | - * element will be written as empty element. So use "" to get a closing tag. |
|
185 | - */ |
|
186 | - public function addHeader($tag, $attributes, $text=null) { |
|
187 | - $this->headers[]= array( |
|
188 | - 'tag' => $tag, |
|
189 | - 'attributes' => $attributes, |
|
190 | - 'text' => $text |
|
191 | - ); |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Process the template |
|
196 | - * @return boolean|string |
|
197 | - * |
|
198 | - * This function process the template. If $this->renderAs is set, it |
|
199 | - * will produce a full page. |
|
200 | - */ |
|
201 | - public function fetchPage($additionalParams = null) { |
|
202 | - $data = parent::fetchPage($additionalParams); |
|
203 | - |
|
204 | - if( $this->renderAs ) { |
|
205 | - $page = new TemplateLayout($this->renderAs, $this->app); |
|
206 | - |
|
207 | - // Add custom headers |
|
208 | - $headers = ''; |
|
209 | - foreach(OC_Util::$headers as $header) { |
|
210 | - $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
|
211 | - foreach($header['attributes'] as $name=>$value) { |
|
212 | - $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
|
213 | - } |
|
214 | - if ($header['text'] !== null) { |
|
215 | - $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>'; |
|
216 | - } else { |
|
217 | - $headers .= '/>'; |
|
218 | - } |
|
219 | - } |
|
220 | - |
|
221 | - $page->assign('headers', $headers); |
|
222 | - |
|
223 | - $page->assign('content', $data); |
|
224 | - return $page->fetchPage(); |
|
225 | - } |
|
226 | - |
|
227 | - return $data; |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Include template |
|
232 | - * |
|
233 | - * @param string $file |
|
234 | - * @param array|null $additionalParams |
|
235 | - * @return string returns content of included template |
|
236 | - * |
|
237 | - * Includes another template. use <?php echo $this->inc('template'); ?> to |
|
238 | - * do this. |
|
239 | - */ |
|
240 | - public function inc( $file, $additionalParams = null ) { |
|
241 | - return $this->load($this->path.$file.'.php', $additionalParams); |
|
242 | - } |
|
243 | - |
|
244 | - /** |
|
245 | - * Shortcut to print a simple page for users |
|
246 | - * @param string $application The application we render the template for |
|
247 | - * @param string $name Name of the template |
|
248 | - * @param array $parameters Parameters for the template |
|
249 | - * @return boolean|null |
|
250 | - */ |
|
251 | - public static function printUserPage( $application, $name, $parameters = array() ) { |
|
252 | - $content = new OC_Template( $application, $name, "user" ); |
|
253 | - foreach( $parameters as $key => $value ) { |
|
254 | - $content->assign( $key, $value ); |
|
255 | - } |
|
256 | - print $content->printPage(); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Shortcut to print a simple page for admins |
|
261 | - * @param string $application The application we render the template for |
|
262 | - * @param string $name Name of the template |
|
263 | - * @param array $parameters Parameters for the template |
|
264 | - * @return bool |
|
265 | - */ |
|
266 | - public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
267 | - $content = new OC_Template( $application, $name, "admin" ); |
|
268 | - foreach( $parameters as $key => $value ) { |
|
269 | - $content->assign( $key, $value ); |
|
270 | - } |
|
271 | - return $content->printPage(); |
|
272 | - } |
|
273 | - |
|
274 | - /** |
|
275 | - * Shortcut to print a simple page for guests |
|
276 | - * @param string $application The application we render the template for |
|
277 | - * @param string $name Name of the template |
|
278 | - * @param array|string $parameters Parameters for the template |
|
279 | - * @return bool |
|
280 | - */ |
|
281 | - public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
282 | - $content = new OC_Template( $application, $name, "guest" ); |
|
283 | - foreach( $parameters as $key => $value ) { |
|
284 | - $content->assign( $key, $value ); |
|
285 | - } |
|
286 | - return $content->printPage(); |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Print a fatal error page and terminates the script |
|
291 | - * @param string $error_msg The error message to show |
|
292 | - * @param string $hint An optional hint message - needs to be properly escaped |
|
293 | - */ |
|
294 | - public static function printErrorPage( $error_msg, $hint = '' ) { |
|
295 | - if ($error_msg === $hint) { |
|
296 | - // If the hint is the same as the message there is no need to display it twice. |
|
297 | - $hint = ''; |
|
298 | - } |
|
299 | - |
|
300 | - try { |
|
301 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
302 | - $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
|
303 | - $content->assign( 'errors', $errors ); |
|
304 | - $content->printPage(); |
|
305 | - } catch (\Exception $e) { |
|
306 | - $logger = \OC::$server->getLogger(); |
|
307 | - $logger->error("$error_msg $hint", ['app' => 'core']); |
|
308 | - $logger->logException($e, ['app' => 'core']); |
|
309 | - |
|
310 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
311 | - header('Content-Type: text/plain; charset=utf-8'); |
|
312 | - print("$error_msg $hint"); |
|
313 | - } |
|
314 | - die(); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * print error page using Exception details |
|
319 | - * @param Exception | Throwable $exception |
|
320 | - */ |
|
321 | - public static function printExceptionErrorPage($exception, $fetchPage = false) { |
|
322 | - try { |
|
323 | - $request = \OC::$server->getRequest(); |
|
324 | - $content = new \OC_Template('', 'exception', 'error', false); |
|
325 | - $content->assign('errorClass', get_class($exception)); |
|
326 | - $content->assign('errorMsg', $exception->getMessage()); |
|
327 | - $content->assign('errorCode', $exception->getCode()); |
|
328 | - $content->assign('file', $exception->getFile()); |
|
329 | - $content->assign('line', $exception->getLine()); |
|
330 | - $content->assign('trace', $exception->getTraceAsString()); |
|
331 | - $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); |
|
332 | - $content->assign('remoteAddr', $request->getRemoteAddress()); |
|
333 | - $content->assign('requestID', $request->getId()); |
|
334 | - if ($fetchPage) { |
|
335 | - return $content->fetchPage(); |
|
336 | - } |
|
337 | - $content->printPage(); |
|
338 | - } catch (\Exception $e) { |
|
339 | - $logger = \OC::$server->getLogger(); |
|
340 | - $logger->logException($exception, ['app' => 'core']); |
|
341 | - $logger->logException($e, ['app' => 'core']); |
|
342 | - |
|
343 | - header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
344 | - header('Content-Type: text/plain; charset=utf-8'); |
|
345 | - print("Internal Server Error\n\n"); |
|
346 | - print("The server encountered an internal error and was unable to complete your request.\n"); |
|
347 | - print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); |
|
348 | - print("More details can be found in the server log.\n"); |
|
349 | - } |
|
350 | - die(); |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * This is only here to reduce the dependencies in case of an exception to |
|
355 | - * still be able to print a plain error message. |
|
356 | - * |
|
357 | - * Returns the used HTTP protocol. |
|
358 | - * |
|
359 | - * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
360 | - * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead |
|
361 | - */ |
|
362 | - protected static function getHttpProtocol() { |
|
363 | - $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
364 | - $validProtocols = [ |
|
365 | - 'HTTP/1.0', |
|
366 | - 'HTTP/1.1', |
|
367 | - 'HTTP/2', |
|
368 | - ]; |
|
369 | - if(in_array($claimedProtocol, $validProtocols, true)) { |
|
370 | - return $claimedProtocol; |
|
371 | - } |
|
372 | - return 'HTTP/1.1'; |
|
373 | - } |
|
47 | + /** @var string */ |
|
48 | + private $renderAs; // Create a full page? |
|
49 | + |
|
50 | + /** @var string */ |
|
51 | + private $path; // The path to the template |
|
52 | + |
|
53 | + /** @var array */ |
|
54 | + private $headers = array(); //custom headers |
|
55 | + |
|
56 | + /** @var string */ |
|
57 | + protected $app; // app id |
|
58 | + |
|
59 | + protected static $initTemplateEngineFirstRun = true; |
|
60 | + |
|
61 | + /** |
|
62 | + * Constructor |
|
63 | + * |
|
64 | + * @param string $app app providing the template |
|
65 | + * @param string $name of the template file (without suffix) |
|
66 | + * @param string $renderAs If $renderAs is set, OC_Template will try to |
|
67 | + * produce a full page in the according layout. For |
|
68 | + * now, $renderAs can be set to "guest", "user" or |
|
69 | + * "admin". |
|
70 | + * @param bool $registerCall = true |
|
71 | + */ |
|
72 | + public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
73 | + // Read the selected theme from the config file |
|
74 | + self::initTemplateEngine($renderAs); |
|
75 | + |
|
76 | + $theme = OC_Util::getTheme(); |
|
77 | + |
|
78 | + $requestToken = (OC::$server->getSession() && $registerCall) ? \OCP\Util::callRegister() : ''; |
|
79 | + |
|
80 | + $parts = explode('/', $app); // fix translation when app is something like core/lostpassword |
|
81 | + $l10n = \OC::$server->getL10N($parts[0]); |
|
82 | + /** @var \OCP\Defaults $themeDefaults */ |
|
83 | + $themeDefaults = \OC::$server->query(\OCP\Defaults::class); |
|
84 | + |
|
85 | + list($path, $template) = $this->findTemplate($theme, $app, $name); |
|
86 | + |
|
87 | + // Set the private data |
|
88 | + $this->renderAs = $renderAs; |
|
89 | + $this->path = $path; |
|
90 | + $this->app = $app; |
|
91 | + |
|
92 | + parent::__construct($template, $requestToken, $l10n, $themeDefaults); |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * @param string $renderAs |
|
97 | + */ |
|
98 | + public static function initTemplateEngine($renderAs) { |
|
99 | + if (self::$initTemplateEngineFirstRun){ |
|
100 | + |
|
101 | + //apps that started before the template initialization can load their own scripts/styles |
|
102 | + //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
|
103 | + //meaning the last script/style in this list will be loaded first |
|
104 | + if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
105 | + if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
106 | + OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + OC_Util::addStyle('jquery-ui-fixes',null,true); |
|
111 | + OC_Util::addVendorStyle('jquery-ui/themes/base/jquery-ui',null,true); |
|
112 | + OC_Util::addStyle('server', null, true); |
|
113 | + OC_Util::addVendorStyle('select2/select2', null, true); |
|
114 | + OC_Util::addStyle('jquery.ocdialog'); |
|
115 | + OC_Util::addTranslations("core", null, true); |
|
116 | + OC_Util::addScript('search', 'search', true); |
|
117 | + OC_Util::addScript('merged-template-prepend', null, true); |
|
118 | + OC_Util::addScript('jquery-ui-fixes'); |
|
119 | + OC_Util::addScript('files/fileinfo'); |
|
120 | + OC_Util::addScript('files/client'); |
|
121 | + OC_Util::addScript('contactsmenu'); |
|
122 | + |
|
123 | + if (\OC::$server->getConfig()->getSystemValue('debug')) { |
|
124 | + // Add the stuff we need always |
|
125 | + // following logic will import all vendor libraries that are |
|
126 | + // specified in core/js/core.json |
|
127 | + $fileContent = file_get_contents(OC::$SERVERROOT . '/core/js/core.json'); |
|
128 | + if($fileContent !== false) { |
|
129 | + $coreDependencies = json_decode($fileContent, true); |
|
130 | + foreach(array_reverse($coreDependencies['vendor']) as $vendorLibrary) { |
|
131 | + //remove trailing ".js" as addVendorScript will append it |
|
132 | + OC_Util::addVendorScript( |
|
133 | + substr($vendorLibrary, 0, strlen($vendorLibrary) - 3),null,true); |
|
134 | + } |
|
135 | + } else { |
|
136 | + throw new \Exception('Cannot read core/js/core.json'); |
|
137 | + } |
|
138 | + } else { |
|
139 | + // Import all (combined) default vendor libraries |
|
140 | + OC_Util::addVendorScript('core', null, true); |
|
141 | + } |
|
142 | + |
|
143 | + if (\OC::$server->getRequest()->isUserAgent([\OC\AppFramework\Http\Request::USER_AGENT_IE])) { |
|
144 | + // polyfill for btoa/atob for IE friends |
|
145 | + OC_Util::addVendorScript('base64/base64'); |
|
146 | + // shim for the davclient.js library |
|
147 | + \OCP\Util::addScript('files/iedavclient'); |
|
148 | + } |
|
149 | + |
|
150 | + self::$initTemplateEngineFirstRun = false; |
|
151 | + } |
|
152 | + |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * find the template with the given name |
|
158 | + * @param string $name of the template file (without suffix) |
|
159 | + * |
|
160 | + * Will select the template file for the selected theme. |
|
161 | + * Checking all the possible locations. |
|
162 | + * @param string $theme |
|
163 | + * @param string $app |
|
164 | + * @return string[] |
|
165 | + */ |
|
166 | + protected function findTemplate($theme, $app, $name) { |
|
167 | + // Check if it is a app template or not. |
|
168 | + if( $app !== '' ) { |
|
169 | + $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
|
170 | + } else { |
|
171 | + $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
|
172 | + } |
|
173 | + $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
174 | + $template = $locator->find($name); |
|
175 | + $path = $locator->getPath(); |
|
176 | + return array($path, $template); |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Add a custom element to the header |
|
181 | + * @param string $tag tag name of the element |
|
182 | + * @param array $attributes array of attributes for the element |
|
183 | + * @param string $text the text content for the element. If $text is null then the |
|
184 | + * element will be written as empty element. So use "" to get a closing tag. |
|
185 | + */ |
|
186 | + public function addHeader($tag, $attributes, $text=null) { |
|
187 | + $this->headers[]= array( |
|
188 | + 'tag' => $tag, |
|
189 | + 'attributes' => $attributes, |
|
190 | + 'text' => $text |
|
191 | + ); |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Process the template |
|
196 | + * @return boolean|string |
|
197 | + * |
|
198 | + * This function process the template. If $this->renderAs is set, it |
|
199 | + * will produce a full page. |
|
200 | + */ |
|
201 | + public function fetchPage($additionalParams = null) { |
|
202 | + $data = parent::fetchPage($additionalParams); |
|
203 | + |
|
204 | + if( $this->renderAs ) { |
|
205 | + $page = new TemplateLayout($this->renderAs, $this->app); |
|
206 | + |
|
207 | + // Add custom headers |
|
208 | + $headers = ''; |
|
209 | + foreach(OC_Util::$headers as $header) { |
|
210 | + $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
|
211 | + foreach($header['attributes'] as $name=>$value) { |
|
212 | + $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
|
213 | + } |
|
214 | + if ($header['text'] !== null) { |
|
215 | + $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).'</'.\OCP\Util::sanitizeHTML($header['tag']).'>'; |
|
216 | + } else { |
|
217 | + $headers .= '/>'; |
|
218 | + } |
|
219 | + } |
|
220 | + |
|
221 | + $page->assign('headers', $headers); |
|
222 | + |
|
223 | + $page->assign('content', $data); |
|
224 | + return $page->fetchPage(); |
|
225 | + } |
|
226 | + |
|
227 | + return $data; |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Include template |
|
232 | + * |
|
233 | + * @param string $file |
|
234 | + * @param array|null $additionalParams |
|
235 | + * @return string returns content of included template |
|
236 | + * |
|
237 | + * Includes another template. use <?php echo $this->inc('template'); ?> to |
|
238 | + * do this. |
|
239 | + */ |
|
240 | + public function inc( $file, $additionalParams = null ) { |
|
241 | + return $this->load($this->path.$file.'.php', $additionalParams); |
|
242 | + } |
|
243 | + |
|
244 | + /** |
|
245 | + * Shortcut to print a simple page for users |
|
246 | + * @param string $application The application we render the template for |
|
247 | + * @param string $name Name of the template |
|
248 | + * @param array $parameters Parameters for the template |
|
249 | + * @return boolean|null |
|
250 | + */ |
|
251 | + public static function printUserPage( $application, $name, $parameters = array() ) { |
|
252 | + $content = new OC_Template( $application, $name, "user" ); |
|
253 | + foreach( $parameters as $key => $value ) { |
|
254 | + $content->assign( $key, $value ); |
|
255 | + } |
|
256 | + print $content->printPage(); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Shortcut to print a simple page for admins |
|
261 | + * @param string $application The application we render the template for |
|
262 | + * @param string $name Name of the template |
|
263 | + * @param array $parameters Parameters for the template |
|
264 | + * @return bool |
|
265 | + */ |
|
266 | + public static function printAdminPage( $application, $name, $parameters = array() ) { |
|
267 | + $content = new OC_Template( $application, $name, "admin" ); |
|
268 | + foreach( $parameters as $key => $value ) { |
|
269 | + $content->assign( $key, $value ); |
|
270 | + } |
|
271 | + return $content->printPage(); |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Shortcut to print a simple page for guests |
|
276 | + * @param string $application The application we render the template for |
|
277 | + * @param string $name Name of the template |
|
278 | + * @param array|string $parameters Parameters for the template |
|
279 | + * @return bool |
|
280 | + */ |
|
281 | + public static function printGuestPage( $application, $name, $parameters = array() ) { |
|
282 | + $content = new OC_Template( $application, $name, "guest" ); |
|
283 | + foreach( $parameters as $key => $value ) { |
|
284 | + $content->assign( $key, $value ); |
|
285 | + } |
|
286 | + return $content->printPage(); |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Print a fatal error page and terminates the script |
|
291 | + * @param string $error_msg The error message to show |
|
292 | + * @param string $hint An optional hint message - needs to be properly escaped |
|
293 | + */ |
|
294 | + public static function printErrorPage( $error_msg, $hint = '' ) { |
|
295 | + if ($error_msg === $hint) { |
|
296 | + // If the hint is the same as the message there is no need to display it twice. |
|
297 | + $hint = ''; |
|
298 | + } |
|
299 | + |
|
300 | + try { |
|
301 | + $content = new \OC_Template( '', 'error', 'error', false ); |
|
302 | + $errors = array(array('error' => $error_msg, 'hint' => $hint)); |
|
303 | + $content->assign( 'errors', $errors ); |
|
304 | + $content->printPage(); |
|
305 | + } catch (\Exception $e) { |
|
306 | + $logger = \OC::$server->getLogger(); |
|
307 | + $logger->error("$error_msg $hint", ['app' => 'core']); |
|
308 | + $logger->logException($e, ['app' => 'core']); |
|
309 | + |
|
310 | + header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
311 | + header('Content-Type: text/plain; charset=utf-8'); |
|
312 | + print("$error_msg $hint"); |
|
313 | + } |
|
314 | + die(); |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * print error page using Exception details |
|
319 | + * @param Exception | Throwable $exception |
|
320 | + */ |
|
321 | + public static function printExceptionErrorPage($exception, $fetchPage = false) { |
|
322 | + try { |
|
323 | + $request = \OC::$server->getRequest(); |
|
324 | + $content = new \OC_Template('', 'exception', 'error', false); |
|
325 | + $content->assign('errorClass', get_class($exception)); |
|
326 | + $content->assign('errorMsg', $exception->getMessage()); |
|
327 | + $content->assign('errorCode', $exception->getCode()); |
|
328 | + $content->assign('file', $exception->getFile()); |
|
329 | + $content->assign('line', $exception->getLine()); |
|
330 | + $content->assign('trace', $exception->getTraceAsString()); |
|
331 | + $content->assign('debugMode', \OC::$server->getSystemConfig()->getValue('debug', false)); |
|
332 | + $content->assign('remoteAddr', $request->getRemoteAddress()); |
|
333 | + $content->assign('requestID', $request->getId()); |
|
334 | + if ($fetchPage) { |
|
335 | + return $content->fetchPage(); |
|
336 | + } |
|
337 | + $content->printPage(); |
|
338 | + } catch (\Exception $e) { |
|
339 | + $logger = \OC::$server->getLogger(); |
|
340 | + $logger->logException($exception, ['app' => 'core']); |
|
341 | + $logger->logException($e, ['app' => 'core']); |
|
342 | + |
|
343 | + header(self::getHttpProtocol() . ' 500 Internal Server Error'); |
|
344 | + header('Content-Type: text/plain; charset=utf-8'); |
|
345 | + print("Internal Server Error\n\n"); |
|
346 | + print("The server encountered an internal error and was unable to complete your request.\n"); |
|
347 | + print("Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.\n"); |
|
348 | + print("More details can be found in the server log.\n"); |
|
349 | + } |
|
350 | + die(); |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * This is only here to reduce the dependencies in case of an exception to |
|
355 | + * still be able to print a plain error message. |
|
356 | + * |
|
357 | + * Returns the used HTTP protocol. |
|
358 | + * |
|
359 | + * @return string HTTP protocol. HTTP/2, HTTP/1.1 or HTTP/1.0. |
|
360 | + * @internal Don't use this - use AppFramework\Http\Request->getHttpProtocol instead |
|
361 | + */ |
|
362 | + protected static function getHttpProtocol() { |
|
363 | + $claimedProtocol = strtoupper($_SERVER['SERVER_PROTOCOL']); |
|
364 | + $validProtocols = [ |
|
365 | + 'HTTP/1.0', |
|
366 | + 'HTTP/1.1', |
|
367 | + 'HTTP/2', |
|
368 | + ]; |
|
369 | + if(in_array($claimedProtocol, $validProtocols, true)) { |
|
370 | + return $claimedProtocol; |
|
371 | + } |
|
372 | + return 'HTTP/1.1'; |
|
373 | + } |
|
374 | 374 | } |
@@ -125,1650 +125,1650 @@ |
||
125 | 125 | * TODO: hookup all manager classes |
126 | 126 | */ |
127 | 127 | class Server extends ServerContainer implements IServerContainer { |
128 | - /** @var string */ |
|
129 | - private $webRoot; |
|
130 | - |
|
131 | - /** |
|
132 | - * @param string $webRoot |
|
133 | - * @param \OC\Config $config |
|
134 | - */ |
|
135 | - public function __construct($webRoot, \OC\Config $config) { |
|
136 | - parent::__construct(); |
|
137 | - $this->webRoot = $webRoot; |
|
138 | - |
|
139 | - $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
140 | - return $c; |
|
141 | - }); |
|
142 | - |
|
143 | - $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
144 | - $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
145 | - |
|
146 | - $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
147 | - |
|
148 | - |
|
149 | - |
|
150 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
151 | - return new PreviewManager( |
|
152 | - $c->getConfig(), |
|
153 | - $c->getRootFolder(), |
|
154 | - $c->getAppDataDir('preview'), |
|
155 | - $c->getEventDispatcher(), |
|
156 | - $c->getSession()->get('user_id') |
|
157 | - ); |
|
158 | - }); |
|
159 | - $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
160 | - |
|
161 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
162 | - return new \OC\Preview\Watcher( |
|
163 | - $c->getAppDataDir('preview') |
|
164 | - ); |
|
165 | - }); |
|
166 | - |
|
167 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
168 | - $view = new View(); |
|
169 | - $util = new Encryption\Util( |
|
170 | - $view, |
|
171 | - $c->getUserManager(), |
|
172 | - $c->getGroupManager(), |
|
173 | - $c->getConfig() |
|
174 | - ); |
|
175 | - return new Encryption\Manager( |
|
176 | - $c->getConfig(), |
|
177 | - $c->getLogger(), |
|
178 | - $c->getL10N('core'), |
|
179 | - new View(), |
|
180 | - $util, |
|
181 | - new ArrayCache() |
|
182 | - ); |
|
183 | - }); |
|
184 | - |
|
185 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
186 | - $util = new Encryption\Util( |
|
187 | - new View(), |
|
188 | - $c->getUserManager(), |
|
189 | - $c->getGroupManager(), |
|
190 | - $c->getConfig() |
|
191 | - ); |
|
192 | - return new Encryption\File( |
|
193 | - $util, |
|
194 | - $c->getRootFolder(), |
|
195 | - $c->getShareManager() |
|
196 | - ); |
|
197 | - }); |
|
198 | - |
|
199 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
200 | - $view = new View(); |
|
201 | - $util = new Encryption\Util( |
|
202 | - $view, |
|
203 | - $c->getUserManager(), |
|
204 | - $c->getGroupManager(), |
|
205 | - $c->getConfig() |
|
206 | - ); |
|
207 | - |
|
208 | - return new Encryption\Keys\Storage($view, $util); |
|
209 | - }); |
|
210 | - $this->registerService('TagMapper', function (Server $c) { |
|
211 | - return new TagMapper($c->getDatabaseConnection()); |
|
212 | - }); |
|
213 | - |
|
214 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
215 | - $tagMapper = $c->query('TagMapper'); |
|
216 | - return new TagManager($tagMapper, $c->getUserSession()); |
|
217 | - }); |
|
218 | - $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
219 | - |
|
220 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
221 | - $config = $c->getConfig(); |
|
222 | - $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
223 | - /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
224 | - $factory = new $factoryClass($this); |
|
225 | - return $factory; |
|
226 | - }); |
|
227 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
228 | - return $c->query('SystemTagManagerFactory')->getManager(); |
|
229 | - }); |
|
230 | - $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
231 | - |
|
232 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
233 | - return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
234 | - }); |
|
235 | - $this->registerService('RootFolder', function (Server $c) { |
|
236 | - $manager = \OC\Files\Filesystem::getMountManager(null); |
|
237 | - $view = new View(); |
|
238 | - $root = new Root( |
|
239 | - $manager, |
|
240 | - $view, |
|
241 | - null, |
|
242 | - $c->getUserMountCache(), |
|
243 | - $this->getLogger(), |
|
244 | - $this->getUserManager() |
|
245 | - ); |
|
246 | - $connector = new HookConnector($root, $view); |
|
247 | - $connector->viewToNode(); |
|
248 | - |
|
249 | - $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
250 | - $previewConnector->connectWatcher(); |
|
251 | - |
|
252 | - return $root; |
|
253 | - }); |
|
254 | - $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
255 | - |
|
256 | - $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
257 | - return new LazyRoot(function() use ($c) { |
|
258 | - return $c->query('RootFolder'); |
|
259 | - }); |
|
260 | - }); |
|
261 | - $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
262 | - |
|
263 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
264 | - $config = $c->getConfig(); |
|
265 | - return new \OC\User\Manager($config); |
|
266 | - }); |
|
267 | - $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
268 | - |
|
269 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
270 | - $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
271 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
272 | - \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
273 | - }); |
|
274 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
275 | - \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
276 | - }); |
|
277 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
278 | - \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
279 | - }); |
|
280 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
281 | - \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
282 | - }); |
|
283 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
284 | - \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
285 | - }); |
|
286 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
287 | - \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
288 | - //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
289 | - \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
290 | - }); |
|
291 | - return $groupManager; |
|
292 | - }); |
|
293 | - $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
294 | - |
|
295 | - $this->registerService(Store::class, function(Server $c) { |
|
296 | - $session = $c->getSession(); |
|
297 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
298 | - $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
299 | - } else { |
|
300 | - $tokenProvider = null; |
|
301 | - } |
|
302 | - $logger = $c->getLogger(); |
|
303 | - return new Store($session, $logger, $tokenProvider); |
|
304 | - }); |
|
305 | - $this->registerAlias(IStore::class, Store::class); |
|
306 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
307 | - $dbConnection = $c->getDatabaseConnection(); |
|
308 | - return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
309 | - }); |
|
310 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
311 | - $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
312 | - $crypto = $c->getCrypto(); |
|
313 | - $config = $c->getConfig(); |
|
314 | - $logger = $c->getLogger(); |
|
315 | - $timeFactory = new TimeFactory(); |
|
316 | - return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
317 | - }); |
|
318 | - $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
319 | - |
|
320 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
321 | - $manager = $c->getUserManager(); |
|
322 | - $session = new \OC\Session\Memory(''); |
|
323 | - $timeFactory = new TimeFactory(); |
|
324 | - // Token providers might require a working database. This code |
|
325 | - // might however be called when ownCloud is not yet setup. |
|
326 | - if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
327 | - $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
328 | - } else { |
|
329 | - $defaultTokenProvider = null; |
|
330 | - } |
|
331 | - |
|
332 | - $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
333 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
334 | - \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
335 | - }); |
|
336 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
337 | - /** @var $user \OC\User\User */ |
|
338 | - \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
339 | - }); |
|
340 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
341 | - /** @var $user \OC\User\User */ |
|
342 | - \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
343 | - }); |
|
344 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
345 | - /** @var $user \OC\User\User */ |
|
346 | - \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
347 | - }); |
|
348 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
349 | - /** @var $user \OC\User\User */ |
|
350 | - \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
351 | - }); |
|
352 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
353 | - /** @var $user \OC\User\User */ |
|
354 | - \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
355 | - }); |
|
356 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
357 | - \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
358 | - }); |
|
359 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
360 | - /** @var $user \OC\User\User */ |
|
361 | - \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
362 | - }); |
|
363 | - $userSession->listen('\OC\User', 'logout', function () { |
|
364 | - \OC_Hook::emit('OC_User', 'logout', array()); |
|
365 | - }); |
|
366 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
367 | - /** @var $user \OC\User\User */ |
|
368 | - \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
369 | - }); |
|
370 | - return $userSession; |
|
371 | - }); |
|
372 | - $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
373 | - |
|
374 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
375 | - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
376 | - }); |
|
377 | - |
|
378 | - $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
379 | - $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
380 | - |
|
381 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
382 | - return new \OC\AllConfig( |
|
383 | - $c->getSystemConfig() |
|
384 | - ); |
|
385 | - }); |
|
386 | - $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
387 | - $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
388 | - |
|
389 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
390 | - return new \OC\SystemConfig($config); |
|
391 | - }); |
|
392 | - |
|
393 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
394 | - return new \OC\AppConfig($c->getDatabaseConnection()); |
|
395 | - }); |
|
396 | - $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
397 | - $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
398 | - |
|
399 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
400 | - return new \OC\L10N\Factory( |
|
401 | - $c->getConfig(), |
|
402 | - $c->getRequest(), |
|
403 | - $c->getUserSession(), |
|
404 | - \OC::$SERVERROOT |
|
405 | - ); |
|
406 | - }); |
|
407 | - $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
408 | - |
|
409 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
410 | - $config = $c->getConfig(); |
|
411 | - $cacheFactory = $c->getMemCacheFactory(); |
|
412 | - return new \OC\URLGenerator( |
|
413 | - $config, |
|
414 | - $cacheFactory |
|
415 | - ); |
|
416 | - }); |
|
417 | - $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
418 | - |
|
419 | - $this->registerService('AppHelper', function ($c) { |
|
420 | - return new \OC\AppHelper(); |
|
421 | - }); |
|
422 | - $this->registerService('AppFetcher', function ($c) { |
|
423 | - return new AppFetcher( |
|
424 | - $this->getAppDataDir('appstore'), |
|
425 | - $this->getHTTPClientService(), |
|
426 | - $this->query(TimeFactory::class), |
|
427 | - $this->getConfig() |
|
428 | - ); |
|
429 | - }); |
|
430 | - $this->registerService('CategoryFetcher', function ($c) { |
|
431 | - return new CategoryFetcher( |
|
432 | - $this->getAppDataDir('appstore'), |
|
433 | - $this->getHTTPClientService(), |
|
434 | - $this->query(TimeFactory::class), |
|
435 | - $this->getConfig() |
|
436 | - ); |
|
437 | - }); |
|
438 | - |
|
439 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
440 | - return new Cache\File(); |
|
441 | - }); |
|
442 | - $this->registerAlias('UserCache', \OCP\ICache::class); |
|
443 | - |
|
444 | - $this->registerService(Factory::class, function (Server $c) { |
|
445 | - $config = $c->getConfig(); |
|
446 | - |
|
447 | - if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
448 | - $v = \OC_App::getAppVersions(); |
|
449 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
450 | - $version = implode(',', $v); |
|
451 | - $instanceId = \OC_Util::getInstanceId(); |
|
452 | - $path = \OC::$SERVERROOT; |
|
453 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
454 | - return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
455 | - $config->getSystemValue('memcache.local', null), |
|
456 | - $config->getSystemValue('memcache.distributed', null), |
|
457 | - $config->getSystemValue('memcache.locking', null) |
|
458 | - ); |
|
459 | - } |
|
460 | - |
|
461 | - return new \OC\Memcache\Factory('', $c->getLogger(), |
|
462 | - '\\OC\\Memcache\\ArrayCache', |
|
463 | - '\\OC\\Memcache\\ArrayCache', |
|
464 | - '\\OC\\Memcache\\ArrayCache' |
|
465 | - ); |
|
466 | - }); |
|
467 | - $this->registerAlias('MemCacheFactory', Factory::class); |
|
468 | - $this->registerAlias(ICacheFactory::class, Factory::class); |
|
469 | - |
|
470 | - $this->registerService('RedisFactory', function (Server $c) { |
|
471 | - $systemConfig = $c->getSystemConfig(); |
|
472 | - return new RedisFactory($systemConfig); |
|
473 | - }); |
|
474 | - |
|
475 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
476 | - return new \OC\Activity\Manager( |
|
477 | - $c->getRequest(), |
|
478 | - $c->getUserSession(), |
|
479 | - $c->getConfig(), |
|
480 | - $c->query(IValidator::class) |
|
481 | - ); |
|
482 | - }); |
|
483 | - $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
484 | - |
|
485 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
486 | - return new \OC\Activity\EventMerger( |
|
487 | - $c->getL10N('lib') |
|
488 | - ); |
|
489 | - }); |
|
490 | - $this->registerAlias(IValidator::class, Validator::class); |
|
491 | - |
|
492 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
493 | - return new AvatarManager( |
|
494 | - $c->getUserManager(), |
|
495 | - $c->getAppDataDir('avatar'), |
|
496 | - $c->getL10N('lib'), |
|
497 | - $c->getLogger(), |
|
498 | - $c->getConfig() |
|
499 | - ); |
|
500 | - }); |
|
501 | - $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
502 | - |
|
503 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
504 | - $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
505 | - $logger = Log::getLogClass($logType); |
|
506 | - call_user_func(array($logger, 'init')); |
|
507 | - |
|
508 | - return new Log($logger); |
|
509 | - }); |
|
510 | - $this->registerAlias('Logger', \OCP\ILogger::class); |
|
511 | - |
|
512 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
513 | - $config = $c->getConfig(); |
|
514 | - return new \OC\BackgroundJob\JobList( |
|
515 | - $c->getDatabaseConnection(), |
|
516 | - $config, |
|
517 | - new TimeFactory() |
|
518 | - ); |
|
519 | - }); |
|
520 | - $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
521 | - |
|
522 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
523 | - $cacheFactory = $c->getMemCacheFactory(); |
|
524 | - $logger = $c->getLogger(); |
|
525 | - if ($cacheFactory->isAvailable()) { |
|
526 | - $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
527 | - } else { |
|
528 | - $router = new \OC\Route\Router($logger); |
|
529 | - } |
|
530 | - return $router; |
|
531 | - }); |
|
532 | - $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
533 | - |
|
534 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
535 | - return new Search(); |
|
536 | - }); |
|
537 | - $this->registerAlias('Search', \OCP\ISearch::class); |
|
538 | - |
|
539 | - $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
540 | - return new \OC\Security\RateLimiting\Limiter( |
|
541 | - $this->getUserSession(), |
|
542 | - $this->getRequest(), |
|
543 | - new \OC\AppFramework\Utility\TimeFactory(), |
|
544 | - $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
545 | - ); |
|
546 | - }); |
|
547 | - $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
548 | - return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
549 | - $this->getMemCacheFactory(), |
|
550 | - new \OC\AppFramework\Utility\TimeFactory() |
|
551 | - ); |
|
552 | - }); |
|
553 | - |
|
554 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
555 | - return new SecureRandom(); |
|
556 | - }); |
|
557 | - $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
558 | - |
|
559 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
560 | - return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
561 | - }); |
|
562 | - $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
563 | - |
|
564 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
565 | - return new Hasher($c->getConfig()); |
|
566 | - }); |
|
567 | - $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
568 | - |
|
569 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
570 | - return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
571 | - }); |
|
572 | - $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
573 | - |
|
574 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
575 | - $systemConfig = $c->getSystemConfig(); |
|
576 | - $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
577 | - $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
578 | - if (!$factory->isValidType($type)) { |
|
579 | - throw new \OC\DatabaseException('Invalid database type'); |
|
580 | - } |
|
581 | - $connectionParams = $factory->createConnectionParams(); |
|
582 | - $connection = $factory->getConnection($type, $connectionParams); |
|
583 | - $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
584 | - return $connection; |
|
585 | - }); |
|
586 | - $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
587 | - |
|
588 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
589 | - $config = $c->getConfig(); |
|
590 | - return new HTTPHelper( |
|
591 | - $config, |
|
592 | - $c->getHTTPClientService() |
|
593 | - ); |
|
594 | - }); |
|
595 | - |
|
596 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
597 | - $user = \OC_User::getUser(); |
|
598 | - $uid = $user ? $user : null; |
|
599 | - return new ClientService( |
|
600 | - $c->getConfig(), |
|
601 | - new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
602 | - ); |
|
603 | - }); |
|
604 | - $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
605 | - |
|
606 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
607 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
608 | - return new EventLogger(); |
|
609 | - } else { |
|
610 | - return new NullEventLogger(); |
|
611 | - } |
|
612 | - }); |
|
613 | - $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
614 | - |
|
615 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
616 | - if ($c->getSystemConfig()->getValue('debug', false)) { |
|
617 | - return new QueryLogger(); |
|
618 | - } else { |
|
619 | - return new NullQueryLogger(); |
|
620 | - } |
|
621 | - }); |
|
622 | - $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
623 | - |
|
624 | - $this->registerService(TempManager::class, function (Server $c) { |
|
625 | - return new TempManager( |
|
626 | - $c->getLogger(), |
|
627 | - $c->getConfig() |
|
628 | - ); |
|
629 | - }); |
|
630 | - $this->registerAlias('TempManager', TempManager::class); |
|
631 | - $this->registerAlias(ITempManager::class, TempManager::class); |
|
632 | - |
|
633 | - $this->registerService(AppManager::class, function (Server $c) { |
|
634 | - return new \OC\App\AppManager( |
|
635 | - $c->getUserSession(), |
|
636 | - $c->getAppConfig(), |
|
637 | - $c->getGroupManager(), |
|
638 | - $c->getMemCacheFactory(), |
|
639 | - $c->getEventDispatcher() |
|
640 | - ); |
|
641 | - }); |
|
642 | - $this->registerAlias('AppManager', AppManager::class); |
|
643 | - $this->registerAlias(IAppManager::class, AppManager::class); |
|
644 | - |
|
645 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
646 | - return new DateTimeZone( |
|
647 | - $c->getConfig(), |
|
648 | - $c->getSession() |
|
649 | - ); |
|
650 | - }); |
|
651 | - $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
652 | - |
|
653 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
654 | - $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
655 | - |
|
656 | - return new DateTimeFormatter( |
|
657 | - $c->getDateTimeZone()->getTimeZone(), |
|
658 | - $c->getL10N('lib', $language) |
|
659 | - ); |
|
660 | - }); |
|
661 | - $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
662 | - |
|
663 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
664 | - $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
665 | - $listener = new UserMountCacheListener($mountCache); |
|
666 | - $listener->listen($c->getUserManager()); |
|
667 | - return $mountCache; |
|
668 | - }); |
|
669 | - $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
670 | - |
|
671 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
672 | - $loader = \OC\Files\Filesystem::getLoader(); |
|
673 | - $mountCache = $c->query('UserMountCache'); |
|
674 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
675 | - |
|
676 | - // builtin providers |
|
677 | - |
|
678 | - $config = $c->getConfig(); |
|
679 | - $manager->registerProvider(new CacheMountProvider($config)); |
|
680 | - $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
681 | - $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
682 | - |
|
683 | - return $manager; |
|
684 | - }); |
|
685 | - $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
686 | - |
|
687 | - $this->registerService('IniWrapper', function ($c) { |
|
688 | - return new IniGetWrapper(); |
|
689 | - }); |
|
690 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
691 | - $jobList = $c->getJobList(); |
|
692 | - return new AsyncBus($jobList); |
|
693 | - }); |
|
694 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
695 | - return new TrustedDomainHelper($this->getConfig()); |
|
696 | - }); |
|
697 | - $this->registerService('Throttler', function(Server $c) { |
|
698 | - return new Throttler( |
|
699 | - $c->getDatabaseConnection(), |
|
700 | - new TimeFactory(), |
|
701 | - $c->getLogger(), |
|
702 | - $c->getConfig() |
|
703 | - ); |
|
704 | - }); |
|
705 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
706 | - // IConfig and IAppManager requires a working database. This code |
|
707 | - // might however be called when ownCloud is not yet setup. |
|
708 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
709 | - $config = $c->getConfig(); |
|
710 | - $appManager = $c->getAppManager(); |
|
711 | - } else { |
|
712 | - $config = null; |
|
713 | - $appManager = null; |
|
714 | - } |
|
715 | - |
|
716 | - return new Checker( |
|
717 | - new EnvironmentHelper(), |
|
718 | - new FileAccessHelper(), |
|
719 | - new AppLocator(), |
|
720 | - $config, |
|
721 | - $c->getMemCacheFactory(), |
|
722 | - $appManager, |
|
723 | - $c->getTempManager() |
|
724 | - ); |
|
725 | - }); |
|
726 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
727 | - if (isset($this['urlParams'])) { |
|
728 | - $urlParams = $this['urlParams']; |
|
729 | - } else { |
|
730 | - $urlParams = []; |
|
731 | - } |
|
732 | - |
|
733 | - if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
734 | - && in_array('fakeinput', stream_get_wrappers()) |
|
735 | - ) { |
|
736 | - $stream = 'fakeinput://data'; |
|
737 | - } else { |
|
738 | - $stream = 'php://input'; |
|
739 | - } |
|
740 | - |
|
741 | - return new Request( |
|
742 | - [ |
|
743 | - 'get' => $_GET, |
|
744 | - 'post' => $_POST, |
|
745 | - 'files' => $_FILES, |
|
746 | - 'server' => $_SERVER, |
|
747 | - 'env' => $_ENV, |
|
748 | - 'cookies' => $_COOKIE, |
|
749 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
750 | - ? $_SERVER['REQUEST_METHOD'] |
|
751 | - : null, |
|
752 | - 'urlParams' => $urlParams, |
|
753 | - ], |
|
754 | - $this->getSecureRandom(), |
|
755 | - $this->getConfig(), |
|
756 | - $this->getCsrfTokenManager(), |
|
757 | - $stream |
|
758 | - ); |
|
759 | - }); |
|
760 | - $this->registerAlias('Request', \OCP\IRequest::class); |
|
761 | - |
|
762 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
763 | - return new Mailer( |
|
764 | - $c->getConfig(), |
|
765 | - $c->getLogger(), |
|
766 | - $c->query(Defaults::class), |
|
767 | - $c->getURLGenerator(), |
|
768 | - $c->getL10N('lib') |
|
769 | - ); |
|
770 | - }); |
|
771 | - $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
772 | - |
|
773 | - $this->registerService('LDAPProvider', function(Server $c) { |
|
774 | - $config = $c->getConfig(); |
|
775 | - $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
776 | - if(is_null($factoryClass)) { |
|
777 | - throw new \Exception('ldapProviderFactory not set'); |
|
778 | - } |
|
779 | - /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
780 | - $factory = new $factoryClass($this); |
|
781 | - return $factory->getLDAPProvider(); |
|
782 | - }); |
|
783 | - $this->registerService('LockingProvider', function (Server $c) { |
|
784 | - $ini = $c->getIniWrapper(); |
|
785 | - $config = $c->getConfig(); |
|
786 | - $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
787 | - if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
788 | - /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
789 | - $memcacheFactory = $c->getMemCacheFactory(); |
|
790 | - $memcache = $memcacheFactory->createLocking('lock'); |
|
791 | - if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
792 | - return new MemcacheLockingProvider($memcache, $ttl); |
|
793 | - } |
|
794 | - return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
795 | - } |
|
796 | - return new NoopLockingProvider(); |
|
797 | - }); |
|
798 | - |
|
799 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
800 | - return new \OC\Files\Mount\Manager(); |
|
801 | - }); |
|
802 | - $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
803 | - |
|
804 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
805 | - return new \OC\Files\Type\Detection( |
|
806 | - $c->getURLGenerator(), |
|
807 | - \OC::$configDir, |
|
808 | - \OC::$SERVERROOT . '/resources/config/' |
|
809 | - ); |
|
810 | - }); |
|
811 | - $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
812 | - |
|
813 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
814 | - return new \OC\Files\Type\Loader( |
|
815 | - $c->getDatabaseConnection() |
|
816 | - ); |
|
817 | - }); |
|
818 | - $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
819 | - |
|
820 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
821 | - return new Manager( |
|
822 | - $c->query(IValidator::class) |
|
823 | - ); |
|
824 | - }); |
|
825 | - $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
826 | - |
|
827 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
828 | - $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
829 | - $manager->registerCapability(function () use ($c) { |
|
830 | - return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
831 | - }); |
|
832 | - return $manager; |
|
833 | - }); |
|
834 | - $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
835 | - |
|
836 | - $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
837 | - $config = $c->getConfig(); |
|
838 | - $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
839 | - /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
840 | - $factory = new $factoryClass($this); |
|
841 | - return $factory->getManager(); |
|
842 | - }); |
|
843 | - $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
844 | - |
|
845 | - $this->registerService('ThemingDefaults', function(Server $c) { |
|
846 | - /* |
|
128 | + /** @var string */ |
|
129 | + private $webRoot; |
|
130 | + |
|
131 | + /** |
|
132 | + * @param string $webRoot |
|
133 | + * @param \OC\Config $config |
|
134 | + */ |
|
135 | + public function __construct($webRoot, \OC\Config $config) { |
|
136 | + parent::__construct(); |
|
137 | + $this->webRoot = $webRoot; |
|
138 | + |
|
139 | + $this->registerService(\OCP\IServerContainer::class, function(IServerContainer $c) { |
|
140 | + return $c; |
|
141 | + }); |
|
142 | + |
|
143 | + $this->registerAlias(\OCP\Contacts\IManager::class, \OC\ContactsManager::class); |
|
144 | + $this->registerAlias('ContactsManager', \OCP\Contacts\IManager::class); |
|
145 | + |
|
146 | + $this->registerAlias(IActionFactory::class, ActionFactory::class); |
|
147 | + |
|
148 | + |
|
149 | + |
|
150 | + $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
151 | + return new PreviewManager( |
|
152 | + $c->getConfig(), |
|
153 | + $c->getRootFolder(), |
|
154 | + $c->getAppDataDir('preview'), |
|
155 | + $c->getEventDispatcher(), |
|
156 | + $c->getSession()->get('user_id') |
|
157 | + ); |
|
158 | + }); |
|
159 | + $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
|
160 | + |
|
161 | + $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
162 | + return new \OC\Preview\Watcher( |
|
163 | + $c->getAppDataDir('preview') |
|
164 | + ); |
|
165 | + }); |
|
166 | + |
|
167 | + $this->registerService('EncryptionManager', function (Server $c) { |
|
168 | + $view = new View(); |
|
169 | + $util = new Encryption\Util( |
|
170 | + $view, |
|
171 | + $c->getUserManager(), |
|
172 | + $c->getGroupManager(), |
|
173 | + $c->getConfig() |
|
174 | + ); |
|
175 | + return new Encryption\Manager( |
|
176 | + $c->getConfig(), |
|
177 | + $c->getLogger(), |
|
178 | + $c->getL10N('core'), |
|
179 | + new View(), |
|
180 | + $util, |
|
181 | + new ArrayCache() |
|
182 | + ); |
|
183 | + }); |
|
184 | + |
|
185 | + $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
186 | + $util = new Encryption\Util( |
|
187 | + new View(), |
|
188 | + $c->getUserManager(), |
|
189 | + $c->getGroupManager(), |
|
190 | + $c->getConfig() |
|
191 | + ); |
|
192 | + return new Encryption\File( |
|
193 | + $util, |
|
194 | + $c->getRootFolder(), |
|
195 | + $c->getShareManager() |
|
196 | + ); |
|
197 | + }); |
|
198 | + |
|
199 | + $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
200 | + $view = new View(); |
|
201 | + $util = new Encryption\Util( |
|
202 | + $view, |
|
203 | + $c->getUserManager(), |
|
204 | + $c->getGroupManager(), |
|
205 | + $c->getConfig() |
|
206 | + ); |
|
207 | + |
|
208 | + return new Encryption\Keys\Storage($view, $util); |
|
209 | + }); |
|
210 | + $this->registerService('TagMapper', function (Server $c) { |
|
211 | + return new TagMapper($c->getDatabaseConnection()); |
|
212 | + }); |
|
213 | + |
|
214 | + $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
215 | + $tagMapper = $c->query('TagMapper'); |
|
216 | + return new TagManager($tagMapper, $c->getUserSession()); |
|
217 | + }); |
|
218 | + $this->registerAlias('TagManager', \OCP\ITagManager::class); |
|
219 | + |
|
220 | + $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
221 | + $config = $c->getConfig(); |
|
222 | + $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
|
223 | + /** @var \OC\SystemTag\ManagerFactory $factory */ |
|
224 | + $factory = new $factoryClass($this); |
|
225 | + return $factory; |
|
226 | + }); |
|
227 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
228 | + return $c->query('SystemTagManagerFactory')->getManager(); |
|
229 | + }); |
|
230 | + $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
|
231 | + |
|
232 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
233 | + return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
|
234 | + }); |
|
235 | + $this->registerService('RootFolder', function (Server $c) { |
|
236 | + $manager = \OC\Files\Filesystem::getMountManager(null); |
|
237 | + $view = new View(); |
|
238 | + $root = new Root( |
|
239 | + $manager, |
|
240 | + $view, |
|
241 | + null, |
|
242 | + $c->getUserMountCache(), |
|
243 | + $this->getLogger(), |
|
244 | + $this->getUserManager() |
|
245 | + ); |
|
246 | + $connector = new HookConnector($root, $view); |
|
247 | + $connector->viewToNode(); |
|
248 | + |
|
249 | + $previewConnector = new \OC\Preview\WatcherConnector($root, $c->getSystemConfig()); |
|
250 | + $previewConnector->connectWatcher(); |
|
251 | + |
|
252 | + return $root; |
|
253 | + }); |
|
254 | + $this->registerAlias('SystemTagObjectMapper', \OCP\SystemTag\ISystemTagObjectMapper::class); |
|
255 | + |
|
256 | + $this->registerService(\OCP\Files\IRootFolder::class, function(Server $c) { |
|
257 | + return new LazyRoot(function() use ($c) { |
|
258 | + return $c->query('RootFolder'); |
|
259 | + }); |
|
260 | + }); |
|
261 | + $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
|
262 | + |
|
263 | + $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
264 | + $config = $c->getConfig(); |
|
265 | + return new \OC\User\Manager($config); |
|
266 | + }); |
|
267 | + $this->registerAlias('UserManager', \OCP\IUserManager::class); |
|
268 | + |
|
269 | + $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
270 | + $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
|
271 | + $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
272 | + \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
|
273 | + }); |
|
274 | + $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
275 | + \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
|
276 | + }); |
|
277 | + $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
278 | + \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
|
279 | + }); |
|
280 | + $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
281 | + \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
|
282 | + }); |
|
283 | + $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
284 | + \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
285 | + }); |
|
286 | + $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
287 | + \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
288 | + //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
|
289 | + \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
|
290 | + }); |
|
291 | + return $groupManager; |
|
292 | + }); |
|
293 | + $this->registerAlias('GroupManager', \OCP\IGroupManager::class); |
|
294 | + |
|
295 | + $this->registerService(Store::class, function(Server $c) { |
|
296 | + $session = $c->getSession(); |
|
297 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
298 | + $tokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
299 | + } else { |
|
300 | + $tokenProvider = null; |
|
301 | + } |
|
302 | + $logger = $c->getLogger(); |
|
303 | + return new Store($session, $logger, $tokenProvider); |
|
304 | + }); |
|
305 | + $this->registerAlias(IStore::class, Store::class); |
|
306 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
307 | + $dbConnection = $c->getDatabaseConnection(); |
|
308 | + return new Authentication\Token\DefaultTokenMapper($dbConnection); |
|
309 | + }); |
|
310 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
311 | + $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
|
312 | + $crypto = $c->getCrypto(); |
|
313 | + $config = $c->getConfig(); |
|
314 | + $logger = $c->getLogger(); |
|
315 | + $timeFactory = new TimeFactory(); |
|
316 | + return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
|
317 | + }); |
|
318 | + $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
|
319 | + |
|
320 | + $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
321 | + $manager = $c->getUserManager(); |
|
322 | + $session = new \OC\Session\Memory(''); |
|
323 | + $timeFactory = new TimeFactory(); |
|
324 | + // Token providers might require a working database. This code |
|
325 | + // might however be called when ownCloud is not yet setup. |
|
326 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
327 | + $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
|
328 | + } else { |
|
329 | + $defaultTokenProvider = null; |
|
330 | + } |
|
331 | + |
|
332 | + $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
|
333 | + $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
334 | + \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
335 | + }); |
|
336 | + $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
337 | + /** @var $user \OC\User\User */ |
|
338 | + \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
|
339 | + }); |
|
340 | + $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
341 | + /** @var $user \OC\User\User */ |
|
342 | + \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
|
343 | + }); |
|
344 | + $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
345 | + /** @var $user \OC\User\User */ |
|
346 | + \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
|
347 | + }); |
|
348 | + $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
349 | + /** @var $user \OC\User\User */ |
|
350 | + \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
351 | + }); |
|
352 | + $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
353 | + /** @var $user \OC\User\User */ |
|
354 | + \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
|
355 | + }); |
|
356 | + $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
357 | + \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
|
358 | + }); |
|
359 | + $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
360 | + /** @var $user \OC\User\User */ |
|
361 | + \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
|
362 | + }); |
|
363 | + $userSession->listen('\OC\User', 'logout', function () { |
|
364 | + \OC_Hook::emit('OC_User', 'logout', array()); |
|
365 | + }); |
|
366 | + $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
367 | + /** @var $user \OC\User\User */ |
|
368 | + \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
|
369 | + }); |
|
370 | + return $userSession; |
|
371 | + }); |
|
372 | + $this->registerAlias('UserSession', \OCP\IUserSession::class); |
|
373 | + |
|
374 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
375 | + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
|
376 | + }); |
|
377 | + |
|
378 | + $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
|
379 | + $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
|
380 | + |
|
381 | + $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
382 | + return new \OC\AllConfig( |
|
383 | + $c->getSystemConfig() |
|
384 | + ); |
|
385 | + }); |
|
386 | + $this->registerAlias('AllConfig', \OC\AllConfig::class); |
|
387 | + $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
|
388 | + |
|
389 | + $this->registerService('SystemConfig', function ($c) use ($config) { |
|
390 | + return new \OC\SystemConfig($config); |
|
391 | + }); |
|
392 | + |
|
393 | + $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
394 | + return new \OC\AppConfig($c->getDatabaseConnection()); |
|
395 | + }); |
|
396 | + $this->registerAlias('AppConfig', \OC\AppConfig::class); |
|
397 | + $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
|
398 | + |
|
399 | + $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
400 | + return new \OC\L10N\Factory( |
|
401 | + $c->getConfig(), |
|
402 | + $c->getRequest(), |
|
403 | + $c->getUserSession(), |
|
404 | + \OC::$SERVERROOT |
|
405 | + ); |
|
406 | + }); |
|
407 | + $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
|
408 | + |
|
409 | + $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
410 | + $config = $c->getConfig(); |
|
411 | + $cacheFactory = $c->getMemCacheFactory(); |
|
412 | + return new \OC\URLGenerator( |
|
413 | + $config, |
|
414 | + $cacheFactory |
|
415 | + ); |
|
416 | + }); |
|
417 | + $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
|
418 | + |
|
419 | + $this->registerService('AppHelper', function ($c) { |
|
420 | + return new \OC\AppHelper(); |
|
421 | + }); |
|
422 | + $this->registerService('AppFetcher', function ($c) { |
|
423 | + return new AppFetcher( |
|
424 | + $this->getAppDataDir('appstore'), |
|
425 | + $this->getHTTPClientService(), |
|
426 | + $this->query(TimeFactory::class), |
|
427 | + $this->getConfig() |
|
428 | + ); |
|
429 | + }); |
|
430 | + $this->registerService('CategoryFetcher', function ($c) { |
|
431 | + return new CategoryFetcher( |
|
432 | + $this->getAppDataDir('appstore'), |
|
433 | + $this->getHTTPClientService(), |
|
434 | + $this->query(TimeFactory::class), |
|
435 | + $this->getConfig() |
|
436 | + ); |
|
437 | + }); |
|
438 | + |
|
439 | + $this->registerService(\OCP\ICache::class, function ($c) { |
|
440 | + return new Cache\File(); |
|
441 | + }); |
|
442 | + $this->registerAlias('UserCache', \OCP\ICache::class); |
|
443 | + |
|
444 | + $this->registerService(Factory::class, function (Server $c) { |
|
445 | + $config = $c->getConfig(); |
|
446 | + |
|
447 | + if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
448 | + $v = \OC_App::getAppVersions(); |
|
449 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
450 | + $version = implode(',', $v); |
|
451 | + $instanceId = \OC_Util::getInstanceId(); |
|
452 | + $path = \OC::$SERVERROOT; |
|
453 | + $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
454 | + return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
|
455 | + $config->getSystemValue('memcache.local', null), |
|
456 | + $config->getSystemValue('memcache.distributed', null), |
|
457 | + $config->getSystemValue('memcache.locking', null) |
|
458 | + ); |
|
459 | + } |
|
460 | + |
|
461 | + return new \OC\Memcache\Factory('', $c->getLogger(), |
|
462 | + '\\OC\\Memcache\\ArrayCache', |
|
463 | + '\\OC\\Memcache\\ArrayCache', |
|
464 | + '\\OC\\Memcache\\ArrayCache' |
|
465 | + ); |
|
466 | + }); |
|
467 | + $this->registerAlias('MemCacheFactory', Factory::class); |
|
468 | + $this->registerAlias(ICacheFactory::class, Factory::class); |
|
469 | + |
|
470 | + $this->registerService('RedisFactory', function (Server $c) { |
|
471 | + $systemConfig = $c->getSystemConfig(); |
|
472 | + return new RedisFactory($systemConfig); |
|
473 | + }); |
|
474 | + |
|
475 | + $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
476 | + return new \OC\Activity\Manager( |
|
477 | + $c->getRequest(), |
|
478 | + $c->getUserSession(), |
|
479 | + $c->getConfig(), |
|
480 | + $c->query(IValidator::class) |
|
481 | + ); |
|
482 | + }); |
|
483 | + $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
|
484 | + |
|
485 | + $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
486 | + return new \OC\Activity\EventMerger( |
|
487 | + $c->getL10N('lib') |
|
488 | + ); |
|
489 | + }); |
|
490 | + $this->registerAlias(IValidator::class, Validator::class); |
|
491 | + |
|
492 | + $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
493 | + return new AvatarManager( |
|
494 | + $c->getUserManager(), |
|
495 | + $c->getAppDataDir('avatar'), |
|
496 | + $c->getL10N('lib'), |
|
497 | + $c->getLogger(), |
|
498 | + $c->getConfig() |
|
499 | + ); |
|
500 | + }); |
|
501 | + $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
|
502 | + |
|
503 | + $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
504 | + $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
|
505 | + $logger = Log::getLogClass($logType); |
|
506 | + call_user_func(array($logger, 'init')); |
|
507 | + |
|
508 | + return new Log($logger); |
|
509 | + }); |
|
510 | + $this->registerAlias('Logger', \OCP\ILogger::class); |
|
511 | + |
|
512 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
513 | + $config = $c->getConfig(); |
|
514 | + return new \OC\BackgroundJob\JobList( |
|
515 | + $c->getDatabaseConnection(), |
|
516 | + $config, |
|
517 | + new TimeFactory() |
|
518 | + ); |
|
519 | + }); |
|
520 | + $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
|
521 | + |
|
522 | + $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
523 | + $cacheFactory = $c->getMemCacheFactory(); |
|
524 | + $logger = $c->getLogger(); |
|
525 | + if ($cacheFactory->isAvailable()) { |
|
526 | + $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
|
527 | + } else { |
|
528 | + $router = new \OC\Route\Router($logger); |
|
529 | + } |
|
530 | + return $router; |
|
531 | + }); |
|
532 | + $this->registerAlias('Router', \OCP\Route\IRouter::class); |
|
533 | + |
|
534 | + $this->registerService(\OCP\ISearch::class, function ($c) { |
|
535 | + return new Search(); |
|
536 | + }); |
|
537 | + $this->registerAlias('Search', \OCP\ISearch::class); |
|
538 | + |
|
539 | + $this->registerService(\OC\Security\RateLimiting\Limiter::class, function($c) { |
|
540 | + return new \OC\Security\RateLimiting\Limiter( |
|
541 | + $this->getUserSession(), |
|
542 | + $this->getRequest(), |
|
543 | + new \OC\AppFramework\Utility\TimeFactory(), |
|
544 | + $c->query(\OC\Security\RateLimiting\Backend\IBackend::class) |
|
545 | + ); |
|
546 | + }); |
|
547 | + $this->registerService(\OC\Security\RateLimiting\Backend\IBackend::class, function($c) { |
|
548 | + return new \OC\Security\RateLimiting\Backend\MemoryCache( |
|
549 | + $this->getMemCacheFactory(), |
|
550 | + new \OC\AppFramework\Utility\TimeFactory() |
|
551 | + ); |
|
552 | + }); |
|
553 | + |
|
554 | + $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
555 | + return new SecureRandom(); |
|
556 | + }); |
|
557 | + $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
|
558 | + |
|
559 | + $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
560 | + return new Crypto($c->getConfig(), $c->getSecureRandom()); |
|
561 | + }); |
|
562 | + $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
|
563 | + |
|
564 | + $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
565 | + return new Hasher($c->getConfig()); |
|
566 | + }); |
|
567 | + $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
|
568 | + |
|
569 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
570 | + return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
|
571 | + }); |
|
572 | + $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
|
573 | + |
|
574 | + $this->registerService(IDBConnection::class, function (Server $c) { |
|
575 | + $systemConfig = $c->getSystemConfig(); |
|
576 | + $factory = new \OC\DB\ConnectionFactory($systemConfig); |
|
577 | + $type = $systemConfig->getValue('dbtype', 'sqlite'); |
|
578 | + if (!$factory->isValidType($type)) { |
|
579 | + throw new \OC\DatabaseException('Invalid database type'); |
|
580 | + } |
|
581 | + $connectionParams = $factory->createConnectionParams(); |
|
582 | + $connection = $factory->getConnection($type, $connectionParams); |
|
583 | + $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
|
584 | + return $connection; |
|
585 | + }); |
|
586 | + $this->registerAlias('DatabaseConnection', IDBConnection::class); |
|
587 | + |
|
588 | + $this->registerService('HTTPHelper', function (Server $c) { |
|
589 | + $config = $c->getConfig(); |
|
590 | + return new HTTPHelper( |
|
591 | + $config, |
|
592 | + $c->getHTTPClientService() |
|
593 | + ); |
|
594 | + }); |
|
595 | + |
|
596 | + $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
597 | + $user = \OC_User::getUser(); |
|
598 | + $uid = $user ? $user : null; |
|
599 | + return new ClientService( |
|
600 | + $c->getConfig(), |
|
601 | + new \OC\Security\CertificateManager($uid, new View(), $c->getConfig(), $c->getLogger()) |
|
602 | + ); |
|
603 | + }); |
|
604 | + $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
|
605 | + |
|
606 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
607 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
608 | + return new EventLogger(); |
|
609 | + } else { |
|
610 | + return new NullEventLogger(); |
|
611 | + } |
|
612 | + }); |
|
613 | + $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
|
614 | + |
|
615 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
616 | + if ($c->getSystemConfig()->getValue('debug', false)) { |
|
617 | + return new QueryLogger(); |
|
618 | + } else { |
|
619 | + return new NullQueryLogger(); |
|
620 | + } |
|
621 | + }); |
|
622 | + $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
|
623 | + |
|
624 | + $this->registerService(TempManager::class, function (Server $c) { |
|
625 | + return new TempManager( |
|
626 | + $c->getLogger(), |
|
627 | + $c->getConfig() |
|
628 | + ); |
|
629 | + }); |
|
630 | + $this->registerAlias('TempManager', TempManager::class); |
|
631 | + $this->registerAlias(ITempManager::class, TempManager::class); |
|
632 | + |
|
633 | + $this->registerService(AppManager::class, function (Server $c) { |
|
634 | + return new \OC\App\AppManager( |
|
635 | + $c->getUserSession(), |
|
636 | + $c->getAppConfig(), |
|
637 | + $c->getGroupManager(), |
|
638 | + $c->getMemCacheFactory(), |
|
639 | + $c->getEventDispatcher() |
|
640 | + ); |
|
641 | + }); |
|
642 | + $this->registerAlias('AppManager', AppManager::class); |
|
643 | + $this->registerAlias(IAppManager::class, AppManager::class); |
|
644 | + |
|
645 | + $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
646 | + return new DateTimeZone( |
|
647 | + $c->getConfig(), |
|
648 | + $c->getSession() |
|
649 | + ); |
|
650 | + }); |
|
651 | + $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
|
652 | + |
|
653 | + $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
654 | + $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
|
655 | + |
|
656 | + return new DateTimeFormatter( |
|
657 | + $c->getDateTimeZone()->getTimeZone(), |
|
658 | + $c->getL10N('lib', $language) |
|
659 | + ); |
|
660 | + }); |
|
661 | + $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
|
662 | + |
|
663 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
664 | + $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
|
665 | + $listener = new UserMountCacheListener($mountCache); |
|
666 | + $listener->listen($c->getUserManager()); |
|
667 | + return $mountCache; |
|
668 | + }); |
|
669 | + $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
|
670 | + |
|
671 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
672 | + $loader = \OC\Files\Filesystem::getLoader(); |
|
673 | + $mountCache = $c->query('UserMountCache'); |
|
674 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
675 | + |
|
676 | + // builtin providers |
|
677 | + |
|
678 | + $config = $c->getConfig(); |
|
679 | + $manager->registerProvider(new CacheMountProvider($config)); |
|
680 | + $manager->registerHomeProvider(new LocalHomeMountProvider()); |
|
681 | + $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
|
682 | + |
|
683 | + return $manager; |
|
684 | + }); |
|
685 | + $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
|
686 | + |
|
687 | + $this->registerService('IniWrapper', function ($c) { |
|
688 | + return new IniGetWrapper(); |
|
689 | + }); |
|
690 | + $this->registerService('AsyncCommandBus', function (Server $c) { |
|
691 | + $jobList = $c->getJobList(); |
|
692 | + return new AsyncBus($jobList); |
|
693 | + }); |
|
694 | + $this->registerService('TrustedDomainHelper', function ($c) { |
|
695 | + return new TrustedDomainHelper($this->getConfig()); |
|
696 | + }); |
|
697 | + $this->registerService('Throttler', function(Server $c) { |
|
698 | + return new Throttler( |
|
699 | + $c->getDatabaseConnection(), |
|
700 | + new TimeFactory(), |
|
701 | + $c->getLogger(), |
|
702 | + $c->getConfig() |
|
703 | + ); |
|
704 | + }); |
|
705 | + $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
706 | + // IConfig and IAppManager requires a working database. This code |
|
707 | + // might however be called when ownCloud is not yet setup. |
|
708 | + if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
709 | + $config = $c->getConfig(); |
|
710 | + $appManager = $c->getAppManager(); |
|
711 | + } else { |
|
712 | + $config = null; |
|
713 | + $appManager = null; |
|
714 | + } |
|
715 | + |
|
716 | + return new Checker( |
|
717 | + new EnvironmentHelper(), |
|
718 | + new FileAccessHelper(), |
|
719 | + new AppLocator(), |
|
720 | + $config, |
|
721 | + $c->getMemCacheFactory(), |
|
722 | + $appManager, |
|
723 | + $c->getTempManager() |
|
724 | + ); |
|
725 | + }); |
|
726 | + $this->registerService(\OCP\IRequest::class, function ($c) { |
|
727 | + if (isset($this['urlParams'])) { |
|
728 | + $urlParams = $this['urlParams']; |
|
729 | + } else { |
|
730 | + $urlParams = []; |
|
731 | + } |
|
732 | + |
|
733 | + if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
|
734 | + && in_array('fakeinput', stream_get_wrappers()) |
|
735 | + ) { |
|
736 | + $stream = 'fakeinput://data'; |
|
737 | + } else { |
|
738 | + $stream = 'php://input'; |
|
739 | + } |
|
740 | + |
|
741 | + return new Request( |
|
742 | + [ |
|
743 | + 'get' => $_GET, |
|
744 | + 'post' => $_POST, |
|
745 | + 'files' => $_FILES, |
|
746 | + 'server' => $_SERVER, |
|
747 | + 'env' => $_ENV, |
|
748 | + 'cookies' => $_COOKIE, |
|
749 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
750 | + ? $_SERVER['REQUEST_METHOD'] |
|
751 | + : null, |
|
752 | + 'urlParams' => $urlParams, |
|
753 | + ], |
|
754 | + $this->getSecureRandom(), |
|
755 | + $this->getConfig(), |
|
756 | + $this->getCsrfTokenManager(), |
|
757 | + $stream |
|
758 | + ); |
|
759 | + }); |
|
760 | + $this->registerAlias('Request', \OCP\IRequest::class); |
|
761 | + |
|
762 | + $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
763 | + return new Mailer( |
|
764 | + $c->getConfig(), |
|
765 | + $c->getLogger(), |
|
766 | + $c->query(Defaults::class), |
|
767 | + $c->getURLGenerator(), |
|
768 | + $c->getL10N('lib') |
|
769 | + ); |
|
770 | + }); |
|
771 | + $this->registerAlias('Mailer', \OCP\Mail\IMailer::class); |
|
772 | + |
|
773 | + $this->registerService('LDAPProvider', function(Server $c) { |
|
774 | + $config = $c->getConfig(); |
|
775 | + $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
|
776 | + if(is_null($factoryClass)) { |
|
777 | + throw new \Exception('ldapProviderFactory not set'); |
|
778 | + } |
|
779 | + /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
|
780 | + $factory = new $factoryClass($this); |
|
781 | + return $factory->getLDAPProvider(); |
|
782 | + }); |
|
783 | + $this->registerService('LockingProvider', function (Server $c) { |
|
784 | + $ini = $c->getIniWrapper(); |
|
785 | + $config = $c->getConfig(); |
|
786 | + $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
|
787 | + if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
|
788 | + /** @var \OC\Memcache\Factory $memcacheFactory */ |
|
789 | + $memcacheFactory = $c->getMemCacheFactory(); |
|
790 | + $memcache = $memcacheFactory->createLocking('lock'); |
|
791 | + if (!($memcache instanceof \OC\Memcache\NullCache)) { |
|
792 | + return new MemcacheLockingProvider($memcache, $ttl); |
|
793 | + } |
|
794 | + return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
|
795 | + } |
|
796 | + return new NoopLockingProvider(); |
|
797 | + }); |
|
798 | + |
|
799 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
800 | + return new \OC\Files\Mount\Manager(); |
|
801 | + }); |
|
802 | + $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
|
803 | + |
|
804 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
805 | + return new \OC\Files\Type\Detection( |
|
806 | + $c->getURLGenerator(), |
|
807 | + \OC::$configDir, |
|
808 | + \OC::$SERVERROOT . '/resources/config/' |
|
809 | + ); |
|
810 | + }); |
|
811 | + $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
|
812 | + |
|
813 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
814 | + return new \OC\Files\Type\Loader( |
|
815 | + $c->getDatabaseConnection() |
|
816 | + ); |
|
817 | + }); |
|
818 | + $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
|
819 | + |
|
820 | + $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
821 | + return new Manager( |
|
822 | + $c->query(IValidator::class) |
|
823 | + ); |
|
824 | + }); |
|
825 | + $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
|
826 | + |
|
827 | + $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
828 | + $manager = new \OC\CapabilitiesManager($c->getLogger()); |
|
829 | + $manager->registerCapability(function () use ($c) { |
|
830 | + return new \OC\OCS\CoreCapabilities($c->getConfig()); |
|
831 | + }); |
|
832 | + return $manager; |
|
833 | + }); |
|
834 | + $this->registerAlias('CapabilitiesManager', \OC\CapabilitiesManager::class); |
|
835 | + |
|
836 | + $this->registerService(\OCP\Comments\ICommentsManager::class, function(Server $c) { |
|
837 | + $config = $c->getConfig(); |
|
838 | + $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
|
839 | + /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
|
840 | + $factory = new $factoryClass($this); |
|
841 | + return $factory->getManager(); |
|
842 | + }); |
|
843 | + $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); |
|
844 | + |
|
845 | + $this->registerService('ThemingDefaults', function(Server $c) { |
|
846 | + /* |
|
847 | 847 | * Dark magic for autoloader. |
848 | 848 | * If we do a class_exists it will try to load the class which will |
849 | 849 | * make composer cache the result. Resulting in errors when enabling |
850 | 850 | * the theming app. |
851 | 851 | */ |
852 | - $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
853 | - if (isset($prefixes['OCA\\Theming\\'])) { |
|
854 | - $classExists = true; |
|
855 | - } else { |
|
856 | - $classExists = false; |
|
857 | - } |
|
858 | - |
|
859 | - if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
860 | - return new ThemingDefaults( |
|
861 | - $c->getConfig(), |
|
862 | - $c->getL10N('theming'), |
|
863 | - $c->getURLGenerator(), |
|
864 | - new \OC_Defaults(), |
|
865 | - $c->getAppDataDir('theming'), |
|
866 | - $c->getMemCacheFactory(), |
|
867 | - new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
868 | - ); |
|
869 | - } |
|
870 | - return new \OC_Defaults(); |
|
871 | - }); |
|
872 | - $this->registerService(SCSSCacher::class, function(Server $c) { |
|
873 | - /** @var Factory $cacheFactory */ |
|
874 | - $cacheFactory = $c->query(Factory::class); |
|
875 | - return new SCSSCacher( |
|
876 | - $c->getLogger(), |
|
877 | - $c->query(\OC\Files\AppData\Factory::class), |
|
878 | - $c->getURLGenerator(), |
|
879 | - $c->getConfig(), |
|
880 | - $c->getThemingDefaults(), |
|
881 | - \OC::$SERVERROOT, |
|
882 | - $cacheFactory->createLocal('SCSS') |
|
883 | - ); |
|
884 | - }); |
|
885 | - $this->registerService(EventDispatcher::class, function () { |
|
886 | - return new EventDispatcher(); |
|
887 | - }); |
|
888 | - $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
889 | - $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
890 | - |
|
891 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
892 | - // FIXME: Instantiiated here due to cyclic dependency |
|
893 | - $request = new Request( |
|
894 | - [ |
|
895 | - 'get' => $_GET, |
|
896 | - 'post' => $_POST, |
|
897 | - 'files' => $_FILES, |
|
898 | - 'server' => $_SERVER, |
|
899 | - 'env' => $_ENV, |
|
900 | - 'cookies' => $_COOKIE, |
|
901 | - 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
902 | - ? $_SERVER['REQUEST_METHOD'] |
|
903 | - : null, |
|
904 | - ], |
|
905 | - $c->getSecureRandom(), |
|
906 | - $c->getConfig() |
|
907 | - ); |
|
908 | - |
|
909 | - return new CryptoWrapper( |
|
910 | - $c->getConfig(), |
|
911 | - $c->getCrypto(), |
|
912 | - $c->getSecureRandom(), |
|
913 | - $request |
|
914 | - ); |
|
915 | - }); |
|
916 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
917 | - $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
918 | - |
|
919 | - return new CsrfTokenManager( |
|
920 | - $tokenGenerator, |
|
921 | - $c->query(SessionStorage::class) |
|
922 | - ); |
|
923 | - }); |
|
924 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
925 | - return new SessionStorage($c->getSession()); |
|
926 | - }); |
|
927 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
928 | - return new ContentSecurityPolicyManager(); |
|
929 | - }); |
|
930 | - $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
931 | - |
|
932 | - $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
933 | - return new ContentSecurityPolicyNonceManager( |
|
934 | - $c->getCsrfTokenManager(), |
|
935 | - $c->getRequest() |
|
936 | - ); |
|
937 | - }); |
|
938 | - |
|
939 | - $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
940 | - $config = $c->getConfig(); |
|
941 | - $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
942 | - /** @var \OCP\Share\IProviderFactory $factory */ |
|
943 | - $factory = new $factoryClass($this); |
|
944 | - |
|
945 | - $manager = new \OC\Share20\Manager( |
|
946 | - $c->getLogger(), |
|
947 | - $c->getConfig(), |
|
948 | - $c->getSecureRandom(), |
|
949 | - $c->getHasher(), |
|
950 | - $c->getMountManager(), |
|
951 | - $c->getGroupManager(), |
|
952 | - $c->getL10N('core'), |
|
953 | - $factory, |
|
954 | - $c->getUserManager(), |
|
955 | - $c->getLazyRootFolder(), |
|
956 | - $c->getEventDispatcher() |
|
957 | - ); |
|
958 | - |
|
959 | - return $manager; |
|
960 | - }); |
|
961 | - $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
962 | - |
|
963 | - $this->registerService('SettingsManager', function(Server $c) { |
|
964 | - $manager = new \OC\Settings\Manager( |
|
965 | - $c->getLogger(), |
|
966 | - $c->getDatabaseConnection(), |
|
967 | - $c->getL10N('lib'), |
|
968 | - $c->getConfig(), |
|
969 | - $c->getEncryptionManager(), |
|
970 | - $c->getUserManager(), |
|
971 | - $c->getLockingProvider(), |
|
972 | - $c->getRequest(), |
|
973 | - new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
974 | - $c->getURLGenerator() |
|
975 | - ); |
|
976 | - return $manager; |
|
977 | - }); |
|
978 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
979 | - return new \OC\Files\AppData\Factory( |
|
980 | - $c->getRootFolder(), |
|
981 | - $c->getSystemConfig() |
|
982 | - ); |
|
983 | - }); |
|
984 | - |
|
985 | - $this->registerService('LockdownManager', function (Server $c) { |
|
986 | - return new LockdownManager(function() use ($c) { |
|
987 | - return $c->getSession(); |
|
988 | - }); |
|
989 | - }); |
|
990 | - |
|
991 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
992 | - return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
993 | - }); |
|
994 | - |
|
995 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
996 | - return new CloudIdManager(); |
|
997 | - }); |
|
998 | - |
|
999 | - /* To trick DI since we don't extend the DIContainer here */ |
|
1000 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
1001 | - return new CleanPreviewsBackgroundJob( |
|
1002 | - $c->getRootFolder(), |
|
1003 | - $c->getLogger(), |
|
1004 | - $c->getJobList(), |
|
1005 | - new TimeFactory() |
|
1006 | - ); |
|
1007 | - }); |
|
1008 | - |
|
1009 | - $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1010 | - $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1011 | - |
|
1012 | - $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1013 | - $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1014 | - |
|
1015 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1016 | - return new Defaults( |
|
1017 | - $c->getThemingDefaults() |
|
1018 | - ); |
|
1019 | - }); |
|
1020 | - $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1021 | - |
|
1022 | - $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1023 | - return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1024 | - }); |
|
1025 | - |
|
1026 | - $this->registerService(IShareHelper::class, function(Server $c) { |
|
1027 | - return new ShareHelper( |
|
1028 | - $c->query(\OCP\Share\IManager::class) |
|
1029 | - ); |
|
1030 | - }); |
|
1031 | - } |
|
1032 | - |
|
1033 | - /** |
|
1034 | - * @return \OCP\Contacts\IManager |
|
1035 | - */ |
|
1036 | - public function getContactsManager() { |
|
1037 | - return $this->query('ContactsManager'); |
|
1038 | - } |
|
1039 | - |
|
1040 | - /** |
|
1041 | - * @return \OC\Encryption\Manager |
|
1042 | - */ |
|
1043 | - public function getEncryptionManager() { |
|
1044 | - return $this->query('EncryptionManager'); |
|
1045 | - } |
|
1046 | - |
|
1047 | - /** |
|
1048 | - * @return \OC\Encryption\File |
|
1049 | - */ |
|
1050 | - public function getEncryptionFilesHelper() { |
|
1051 | - return $this->query('EncryptionFileHelper'); |
|
1052 | - } |
|
1053 | - |
|
1054 | - /** |
|
1055 | - * @return \OCP\Encryption\Keys\IStorage |
|
1056 | - */ |
|
1057 | - public function getEncryptionKeyStorage() { |
|
1058 | - return $this->query('EncryptionKeyStorage'); |
|
1059 | - } |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * The current request object holding all information about the request |
|
1063 | - * currently being processed is returned from this method. |
|
1064 | - * In case the current execution was not initiated by a web request null is returned |
|
1065 | - * |
|
1066 | - * @return \OCP\IRequest |
|
1067 | - */ |
|
1068 | - public function getRequest() { |
|
1069 | - return $this->query('Request'); |
|
1070 | - } |
|
1071 | - |
|
1072 | - /** |
|
1073 | - * Returns the preview manager which can create preview images for a given file |
|
1074 | - * |
|
1075 | - * @return \OCP\IPreview |
|
1076 | - */ |
|
1077 | - public function getPreviewManager() { |
|
1078 | - return $this->query('PreviewManager'); |
|
1079 | - } |
|
1080 | - |
|
1081 | - /** |
|
1082 | - * Returns the tag manager which can get and set tags for different object types |
|
1083 | - * |
|
1084 | - * @see \OCP\ITagManager::load() |
|
1085 | - * @return \OCP\ITagManager |
|
1086 | - */ |
|
1087 | - public function getTagManager() { |
|
1088 | - return $this->query('TagManager'); |
|
1089 | - } |
|
1090 | - |
|
1091 | - /** |
|
1092 | - * Returns the system-tag manager |
|
1093 | - * |
|
1094 | - * @return \OCP\SystemTag\ISystemTagManager |
|
1095 | - * |
|
1096 | - * @since 9.0.0 |
|
1097 | - */ |
|
1098 | - public function getSystemTagManager() { |
|
1099 | - return $this->query('SystemTagManager'); |
|
1100 | - } |
|
1101 | - |
|
1102 | - /** |
|
1103 | - * Returns the system-tag object mapper |
|
1104 | - * |
|
1105 | - * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1106 | - * |
|
1107 | - * @since 9.0.0 |
|
1108 | - */ |
|
1109 | - public function getSystemTagObjectMapper() { |
|
1110 | - return $this->query('SystemTagObjectMapper'); |
|
1111 | - } |
|
1112 | - |
|
1113 | - /** |
|
1114 | - * Returns the avatar manager, used for avatar functionality |
|
1115 | - * |
|
1116 | - * @return \OCP\IAvatarManager |
|
1117 | - */ |
|
1118 | - public function getAvatarManager() { |
|
1119 | - return $this->query('AvatarManager'); |
|
1120 | - } |
|
1121 | - |
|
1122 | - /** |
|
1123 | - * Returns the root folder of ownCloud's data directory |
|
1124 | - * |
|
1125 | - * @return \OCP\Files\IRootFolder |
|
1126 | - */ |
|
1127 | - public function getRootFolder() { |
|
1128 | - return $this->query('LazyRootFolder'); |
|
1129 | - } |
|
1130 | - |
|
1131 | - /** |
|
1132 | - * Returns the root folder of ownCloud's data directory |
|
1133 | - * This is the lazy variant so this gets only initialized once it |
|
1134 | - * is actually used. |
|
1135 | - * |
|
1136 | - * @return \OCP\Files\IRootFolder |
|
1137 | - */ |
|
1138 | - public function getLazyRootFolder() { |
|
1139 | - return $this->query('LazyRootFolder'); |
|
1140 | - } |
|
1141 | - |
|
1142 | - /** |
|
1143 | - * Returns a view to ownCloud's files folder |
|
1144 | - * |
|
1145 | - * @param string $userId user ID |
|
1146 | - * @return \OCP\Files\Folder|null |
|
1147 | - */ |
|
1148 | - public function getUserFolder($userId = null) { |
|
1149 | - if ($userId === null) { |
|
1150 | - $user = $this->getUserSession()->getUser(); |
|
1151 | - if (!$user) { |
|
1152 | - return null; |
|
1153 | - } |
|
1154 | - $userId = $user->getUID(); |
|
1155 | - } |
|
1156 | - $root = $this->getRootFolder(); |
|
1157 | - return $root->getUserFolder($userId); |
|
1158 | - } |
|
1159 | - |
|
1160 | - /** |
|
1161 | - * Returns an app-specific view in ownClouds data directory |
|
1162 | - * |
|
1163 | - * @return \OCP\Files\Folder |
|
1164 | - * @deprecated since 9.2.0 use IAppData |
|
1165 | - */ |
|
1166 | - public function getAppFolder() { |
|
1167 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1168 | - $root = $this->getRootFolder(); |
|
1169 | - if (!$root->nodeExists($dir)) { |
|
1170 | - $folder = $root->newFolder($dir); |
|
1171 | - } else { |
|
1172 | - $folder = $root->get($dir); |
|
1173 | - } |
|
1174 | - return $folder; |
|
1175 | - } |
|
1176 | - |
|
1177 | - /** |
|
1178 | - * @return \OC\User\Manager |
|
1179 | - */ |
|
1180 | - public function getUserManager() { |
|
1181 | - return $this->query('UserManager'); |
|
1182 | - } |
|
1183 | - |
|
1184 | - /** |
|
1185 | - * @return \OC\Group\Manager |
|
1186 | - */ |
|
1187 | - public function getGroupManager() { |
|
1188 | - return $this->query('GroupManager'); |
|
1189 | - } |
|
1190 | - |
|
1191 | - /** |
|
1192 | - * @return \OC\User\Session |
|
1193 | - */ |
|
1194 | - public function getUserSession() { |
|
1195 | - return $this->query('UserSession'); |
|
1196 | - } |
|
1197 | - |
|
1198 | - /** |
|
1199 | - * @return \OCP\ISession |
|
1200 | - */ |
|
1201 | - public function getSession() { |
|
1202 | - return $this->query('UserSession')->getSession(); |
|
1203 | - } |
|
1204 | - |
|
1205 | - /** |
|
1206 | - * @param \OCP\ISession $session |
|
1207 | - */ |
|
1208 | - public function setSession(\OCP\ISession $session) { |
|
1209 | - $this->query(SessionStorage::class)->setSession($session); |
|
1210 | - $this->query('UserSession')->setSession($session); |
|
1211 | - $this->query(Store::class)->setSession($session); |
|
1212 | - } |
|
1213 | - |
|
1214 | - /** |
|
1215 | - * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1216 | - */ |
|
1217 | - public function getTwoFactorAuthManager() { |
|
1218 | - return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1219 | - } |
|
1220 | - |
|
1221 | - /** |
|
1222 | - * @return \OC\NavigationManager |
|
1223 | - */ |
|
1224 | - public function getNavigationManager() { |
|
1225 | - return $this->query('NavigationManager'); |
|
1226 | - } |
|
1227 | - |
|
1228 | - /** |
|
1229 | - * @return \OCP\IConfig |
|
1230 | - */ |
|
1231 | - public function getConfig() { |
|
1232 | - return $this->query('AllConfig'); |
|
1233 | - } |
|
1234 | - |
|
1235 | - /** |
|
1236 | - * @internal For internal use only |
|
1237 | - * @return \OC\SystemConfig |
|
1238 | - */ |
|
1239 | - public function getSystemConfig() { |
|
1240 | - return $this->query('SystemConfig'); |
|
1241 | - } |
|
1242 | - |
|
1243 | - /** |
|
1244 | - * Returns the app config manager |
|
1245 | - * |
|
1246 | - * @return \OCP\IAppConfig |
|
1247 | - */ |
|
1248 | - public function getAppConfig() { |
|
1249 | - return $this->query('AppConfig'); |
|
1250 | - } |
|
1251 | - |
|
1252 | - /** |
|
1253 | - * @return \OCP\L10N\IFactory |
|
1254 | - */ |
|
1255 | - public function getL10NFactory() { |
|
1256 | - return $this->query('L10NFactory'); |
|
1257 | - } |
|
1258 | - |
|
1259 | - /** |
|
1260 | - * get an L10N instance |
|
1261 | - * |
|
1262 | - * @param string $app appid |
|
1263 | - * @param string $lang |
|
1264 | - * @return IL10N |
|
1265 | - */ |
|
1266 | - public function getL10N($app, $lang = null) { |
|
1267 | - return $this->getL10NFactory()->get($app, $lang); |
|
1268 | - } |
|
1269 | - |
|
1270 | - /** |
|
1271 | - * @return \OCP\IURLGenerator |
|
1272 | - */ |
|
1273 | - public function getURLGenerator() { |
|
1274 | - return $this->query('URLGenerator'); |
|
1275 | - } |
|
1276 | - |
|
1277 | - /** |
|
1278 | - * @return \OCP\IHelper |
|
1279 | - */ |
|
1280 | - public function getHelper() { |
|
1281 | - return $this->query('AppHelper'); |
|
1282 | - } |
|
1283 | - |
|
1284 | - /** |
|
1285 | - * @return AppFetcher |
|
1286 | - */ |
|
1287 | - public function getAppFetcher() { |
|
1288 | - return $this->query('AppFetcher'); |
|
1289 | - } |
|
1290 | - |
|
1291 | - /** |
|
1292 | - * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1293 | - * getMemCacheFactory() instead. |
|
1294 | - * |
|
1295 | - * @return \OCP\ICache |
|
1296 | - * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1297 | - */ |
|
1298 | - public function getCache() { |
|
1299 | - return $this->query('UserCache'); |
|
1300 | - } |
|
1301 | - |
|
1302 | - /** |
|
1303 | - * Returns an \OCP\CacheFactory instance |
|
1304 | - * |
|
1305 | - * @return \OCP\ICacheFactory |
|
1306 | - */ |
|
1307 | - public function getMemCacheFactory() { |
|
1308 | - return $this->query('MemCacheFactory'); |
|
1309 | - } |
|
1310 | - |
|
1311 | - /** |
|
1312 | - * Returns an \OC\RedisFactory instance |
|
1313 | - * |
|
1314 | - * @return \OC\RedisFactory |
|
1315 | - */ |
|
1316 | - public function getGetRedisFactory() { |
|
1317 | - return $this->query('RedisFactory'); |
|
1318 | - } |
|
1319 | - |
|
1320 | - |
|
1321 | - /** |
|
1322 | - * Returns the current session |
|
1323 | - * |
|
1324 | - * @return \OCP\IDBConnection |
|
1325 | - */ |
|
1326 | - public function getDatabaseConnection() { |
|
1327 | - return $this->query('DatabaseConnection'); |
|
1328 | - } |
|
1329 | - |
|
1330 | - /** |
|
1331 | - * Returns the activity manager |
|
1332 | - * |
|
1333 | - * @return \OCP\Activity\IManager |
|
1334 | - */ |
|
1335 | - public function getActivityManager() { |
|
1336 | - return $this->query('ActivityManager'); |
|
1337 | - } |
|
1338 | - |
|
1339 | - /** |
|
1340 | - * Returns an job list for controlling background jobs |
|
1341 | - * |
|
1342 | - * @return \OCP\BackgroundJob\IJobList |
|
1343 | - */ |
|
1344 | - public function getJobList() { |
|
1345 | - return $this->query('JobList'); |
|
1346 | - } |
|
1347 | - |
|
1348 | - /** |
|
1349 | - * Returns a logger instance |
|
1350 | - * |
|
1351 | - * @return \OCP\ILogger |
|
1352 | - */ |
|
1353 | - public function getLogger() { |
|
1354 | - return $this->query('Logger'); |
|
1355 | - } |
|
1356 | - |
|
1357 | - /** |
|
1358 | - * Returns a router for generating and matching urls |
|
1359 | - * |
|
1360 | - * @return \OCP\Route\IRouter |
|
1361 | - */ |
|
1362 | - public function getRouter() { |
|
1363 | - return $this->query('Router'); |
|
1364 | - } |
|
1365 | - |
|
1366 | - /** |
|
1367 | - * Returns a search instance |
|
1368 | - * |
|
1369 | - * @return \OCP\ISearch |
|
1370 | - */ |
|
1371 | - public function getSearch() { |
|
1372 | - return $this->query('Search'); |
|
1373 | - } |
|
1374 | - |
|
1375 | - /** |
|
1376 | - * Returns a SecureRandom instance |
|
1377 | - * |
|
1378 | - * @return \OCP\Security\ISecureRandom |
|
1379 | - */ |
|
1380 | - public function getSecureRandom() { |
|
1381 | - return $this->query('SecureRandom'); |
|
1382 | - } |
|
1383 | - |
|
1384 | - /** |
|
1385 | - * Returns a Crypto instance |
|
1386 | - * |
|
1387 | - * @return \OCP\Security\ICrypto |
|
1388 | - */ |
|
1389 | - public function getCrypto() { |
|
1390 | - return $this->query('Crypto'); |
|
1391 | - } |
|
1392 | - |
|
1393 | - /** |
|
1394 | - * Returns a Hasher instance |
|
1395 | - * |
|
1396 | - * @return \OCP\Security\IHasher |
|
1397 | - */ |
|
1398 | - public function getHasher() { |
|
1399 | - return $this->query('Hasher'); |
|
1400 | - } |
|
1401 | - |
|
1402 | - /** |
|
1403 | - * Returns a CredentialsManager instance |
|
1404 | - * |
|
1405 | - * @return \OCP\Security\ICredentialsManager |
|
1406 | - */ |
|
1407 | - public function getCredentialsManager() { |
|
1408 | - return $this->query('CredentialsManager'); |
|
1409 | - } |
|
1410 | - |
|
1411 | - /** |
|
1412 | - * Returns an instance of the HTTP helper class |
|
1413 | - * |
|
1414 | - * @deprecated Use getHTTPClientService() |
|
1415 | - * @return \OC\HTTPHelper |
|
1416 | - */ |
|
1417 | - public function getHTTPHelper() { |
|
1418 | - return $this->query('HTTPHelper'); |
|
1419 | - } |
|
1420 | - |
|
1421 | - /** |
|
1422 | - * Get the certificate manager for the user |
|
1423 | - * |
|
1424 | - * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1425 | - * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1426 | - */ |
|
1427 | - public function getCertificateManager($userId = '') { |
|
1428 | - if ($userId === '') { |
|
1429 | - $userSession = $this->getUserSession(); |
|
1430 | - $user = $userSession->getUser(); |
|
1431 | - if (is_null($user)) { |
|
1432 | - return null; |
|
1433 | - } |
|
1434 | - $userId = $user->getUID(); |
|
1435 | - } |
|
1436 | - return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1437 | - } |
|
1438 | - |
|
1439 | - /** |
|
1440 | - * Returns an instance of the HTTP client service |
|
1441 | - * |
|
1442 | - * @return \OCP\Http\Client\IClientService |
|
1443 | - */ |
|
1444 | - public function getHTTPClientService() { |
|
1445 | - return $this->query('HttpClientService'); |
|
1446 | - } |
|
1447 | - |
|
1448 | - /** |
|
1449 | - * Create a new event source |
|
1450 | - * |
|
1451 | - * @return \OCP\IEventSource |
|
1452 | - */ |
|
1453 | - public function createEventSource() { |
|
1454 | - return new \OC_EventSource(); |
|
1455 | - } |
|
1456 | - |
|
1457 | - /** |
|
1458 | - * Get the active event logger |
|
1459 | - * |
|
1460 | - * The returned logger only logs data when debug mode is enabled |
|
1461 | - * |
|
1462 | - * @return \OCP\Diagnostics\IEventLogger |
|
1463 | - */ |
|
1464 | - public function getEventLogger() { |
|
1465 | - return $this->query('EventLogger'); |
|
1466 | - } |
|
1467 | - |
|
1468 | - /** |
|
1469 | - * Get the active query logger |
|
1470 | - * |
|
1471 | - * The returned logger only logs data when debug mode is enabled |
|
1472 | - * |
|
1473 | - * @return \OCP\Diagnostics\IQueryLogger |
|
1474 | - */ |
|
1475 | - public function getQueryLogger() { |
|
1476 | - return $this->query('QueryLogger'); |
|
1477 | - } |
|
1478 | - |
|
1479 | - /** |
|
1480 | - * Get the manager for temporary files and folders |
|
1481 | - * |
|
1482 | - * @return \OCP\ITempManager |
|
1483 | - */ |
|
1484 | - public function getTempManager() { |
|
1485 | - return $this->query('TempManager'); |
|
1486 | - } |
|
1487 | - |
|
1488 | - /** |
|
1489 | - * Get the app manager |
|
1490 | - * |
|
1491 | - * @return \OCP\App\IAppManager |
|
1492 | - */ |
|
1493 | - public function getAppManager() { |
|
1494 | - return $this->query('AppManager'); |
|
1495 | - } |
|
1496 | - |
|
1497 | - /** |
|
1498 | - * Creates a new mailer |
|
1499 | - * |
|
1500 | - * @return \OCP\Mail\IMailer |
|
1501 | - */ |
|
1502 | - public function getMailer() { |
|
1503 | - return $this->query('Mailer'); |
|
1504 | - } |
|
1505 | - |
|
1506 | - /** |
|
1507 | - * Get the webroot |
|
1508 | - * |
|
1509 | - * @return string |
|
1510 | - */ |
|
1511 | - public function getWebRoot() { |
|
1512 | - return $this->webRoot; |
|
1513 | - } |
|
1514 | - |
|
1515 | - /** |
|
1516 | - * @return \OC\OCSClient |
|
1517 | - */ |
|
1518 | - public function getOcsClient() { |
|
1519 | - return $this->query('OcsClient'); |
|
1520 | - } |
|
1521 | - |
|
1522 | - /** |
|
1523 | - * @return \OCP\IDateTimeZone |
|
1524 | - */ |
|
1525 | - public function getDateTimeZone() { |
|
1526 | - return $this->query('DateTimeZone'); |
|
1527 | - } |
|
1528 | - |
|
1529 | - /** |
|
1530 | - * @return \OCP\IDateTimeFormatter |
|
1531 | - */ |
|
1532 | - public function getDateTimeFormatter() { |
|
1533 | - return $this->query('DateTimeFormatter'); |
|
1534 | - } |
|
1535 | - |
|
1536 | - /** |
|
1537 | - * @return \OCP\Files\Config\IMountProviderCollection |
|
1538 | - */ |
|
1539 | - public function getMountProviderCollection() { |
|
1540 | - return $this->query('MountConfigManager'); |
|
1541 | - } |
|
1542 | - |
|
1543 | - /** |
|
1544 | - * Get the IniWrapper |
|
1545 | - * |
|
1546 | - * @return IniGetWrapper |
|
1547 | - */ |
|
1548 | - public function getIniWrapper() { |
|
1549 | - return $this->query('IniWrapper'); |
|
1550 | - } |
|
1551 | - |
|
1552 | - /** |
|
1553 | - * @return \OCP\Command\IBus |
|
1554 | - */ |
|
1555 | - public function getCommandBus() { |
|
1556 | - return $this->query('AsyncCommandBus'); |
|
1557 | - } |
|
1558 | - |
|
1559 | - /** |
|
1560 | - * Get the trusted domain helper |
|
1561 | - * |
|
1562 | - * @return TrustedDomainHelper |
|
1563 | - */ |
|
1564 | - public function getTrustedDomainHelper() { |
|
1565 | - return $this->query('TrustedDomainHelper'); |
|
1566 | - } |
|
1567 | - |
|
1568 | - /** |
|
1569 | - * Get the locking provider |
|
1570 | - * |
|
1571 | - * @return \OCP\Lock\ILockingProvider |
|
1572 | - * @since 8.1.0 |
|
1573 | - */ |
|
1574 | - public function getLockingProvider() { |
|
1575 | - return $this->query('LockingProvider'); |
|
1576 | - } |
|
1577 | - |
|
1578 | - /** |
|
1579 | - * @return \OCP\Files\Mount\IMountManager |
|
1580 | - **/ |
|
1581 | - function getMountManager() { |
|
1582 | - return $this->query('MountManager'); |
|
1583 | - } |
|
1584 | - |
|
1585 | - /** @return \OCP\Files\Config\IUserMountCache */ |
|
1586 | - function getUserMountCache() { |
|
1587 | - return $this->query('UserMountCache'); |
|
1588 | - } |
|
1589 | - |
|
1590 | - /** |
|
1591 | - * Get the MimeTypeDetector |
|
1592 | - * |
|
1593 | - * @return \OCP\Files\IMimeTypeDetector |
|
1594 | - */ |
|
1595 | - public function getMimeTypeDetector() { |
|
1596 | - return $this->query('MimeTypeDetector'); |
|
1597 | - } |
|
1598 | - |
|
1599 | - /** |
|
1600 | - * Get the MimeTypeLoader |
|
1601 | - * |
|
1602 | - * @return \OCP\Files\IMimeTypeLoader |
|
1603 | - */ |
|
1604 | - public function getMimeTypeLoader() { |
|
1605 | - return $this->query('MimeTypeLoader'); |
|
1606 | - } |
|
1607 | - |
|
1608 | - /** |
|
1609 | - * Get the manager of all the capabilities |
|
1610 | - * |
|
1611 | - * @return \OC\CapabilitiesManager |
|
1612 | - */ |
|
1613 | - public function getCapabilitiesManager() { |
|
1614 | - return $this->query('CapabilitiesManager'); |
|
1615 | - } |
|
1616 | - |
|
1617 | - /** |
|
1618 | - * Get the EventDispatcher |
|
1619 | - * |
|
1620 | - * @return EventDispatcherInterface |
|
1621 | - * @since 8.2.0 |
|
1622 | - */ |
|
1623 | - public function getEventDispatcher() { |
|
1624 | - return $this->query('EventDispatcher'); |
|
1625 | - } |
|
1626 | - |
|
1627 | - /** |
|
1628 | - * Get the Notification Manager |
|
1629 | - * |
|
1630 | - * @return \OCP\Notification\IManager |
|
1631 | - * @since 8.2.0 |
|
1632 | - */ |
|
1633 | - public function getNotificationManager() { |
|
1634 | - return $this->query('NotificationManager'); |
|
1635 | - } |
|
1636 | - |
|
1637 | - /** |
|
1638 | - * @return \OCP\Comments\ICommentsManager |
|
1639 | - */ |
|
1640 | - public function getCommentsManager() { |
|
1641 | - return $this->query('CommentsManager'); |
|
1642 | - } |
|
1643 | - |
|
1644 | - /** |
|
1645 | - * @return \OCA\Theming\ThemingDefaults |
|
1646 | - */ |
|
1647 | - public function getThemingDefaults() { |
|
1648 | - return $this->query('ThemingDefaults'); |
|
1649 | - } |
|
1650 | - |
|
1651 | - /** |
|
1652 | - * @return \OC\IntegrityCheck\Checker |
|
1653 | - */ |
|
1654 | - public function getIntegrityCodeChecker() { |
|
1655 | - return $this->query('IntegrityCodeChecker'); |
|
1656 | - } |
|
1657 | - |
|
1658 | - /** |
|
1659 | - * @return \OC\Session\CryptoWrapper |
|
1660 | - */ |
|
1661 | - public function getSessionCryptoWrapper() { |
|
1662 | - return $this->query('CryptoWrapper'); |
|
1663 | - } |
|
1664 | - |
|
1665 | - /** |
|
1666 | - * @return CsrfTokenManager |
|
1667 | - */ |
|
1668 | - public function getCsrfTokenManager() { |
|
1669 | - return $this->query('CsrfTokenManager'); |
|
1670 | - } |
|
1671 | - |
|
1672 | - /** |
|
1673 | - * @return Throttler |
|
1674 | - */ |
|
1675 | - public function getBruteForceThrottler() { |
|
1676 | - return $this->query('Throttler'); |
|
1677 | - } |
|
1678 | - |
|
1679 | - /** |
|
1680 | - * @return IContentSecurityPolicyManager |
|
1681 | - */ |
|
1682 | - public function getContentSecurityPolicyManager() { |
|
1683 | - return $this->query('ContentSecurityPolicyManager'); |
|
1684 | - } |
|
1685 | - |
|
1686 | - /** |
|
1687 | - * @return ContentSecurityPolicyNonceManager |
|
1688 | - */ |
|
1689 | - public function getContentSecurityPolicyNonceManager() { |
|
1690 | - return $this->query('ContentSecurityPolicyNonceManager'); |
|
1691 | - } |
|
1692 | - |
|
1693 | - /** |
|
1694 | - * Not a public API as of 8.2, wait for 9.0 |
|
1695 | - * |
|
1696 | - * @return \OCA\Files_External\Service\BackendService |
|
1697 | - */ |
|
1698 | - public function getStoragesBackendService() { |
|
1699 | - return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1700 | - } |
|
1701 | - |
|
1702 | - /** |
|
1703 | - * Not a public API as of 8.2, wait for 9.0 |
|
1704 | - * |
|
1705 | - * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1706 | - */ |
|
1707 | - public function getGlobalStoragesService() { |
|
1708 | - return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1709 | - } |
|
1710 | - |
|
1711 | - /** |
|
1712 | - * Not a public API as of 8.2, wait for 9.0 |
|
1713 | - * |
|
1714 | - * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1715 | - */ |
|
1716 | - public function getUserGlobalStoragesService() { |
|
1717 | - return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1718 | - } |
|
1719 | - |
|
1720 | - /** |
|
1721 | - * Not a public API as of 8.2, wait for 9.0 |
|
1722 | - * |
|
1723 | - * @return \OCA\Files_External\Service\UserStoragesService |
|
1724 | - */ |
|
1725 | - public function getUserStoragesService() { |
|
1726 | - return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1727 | - } |
|
1728 | - |
|
1729 | - /** |
|
1730 | - * @return \OCP\Share\IManager |
|
1731 | - */ |
|
1732 | - public function getShareManager() { |
|
1733 | - return $this->query('ShareManager'); |
|
1734 | - } |
|
1735 | - |
|
1736 | - /** |
|
1737 | - * Returns the LDAP Provider |
|
1738 | - * |
|
1739 | - * @return \OCP\LDAP\ILDAPProvider |
|
1740 | - */ |
|
1741 | - public function getLDAPProvider() { |
|
1742 | - return $this->query('LDAPProvider'); |
|
1743 | - } |
|
1744 | - |
|
1745 | - /** |
|
1746 | - * @return \OCP\Settings\IManager |
|
1747 | - */ |
|
1748 | - public function getSettingsManager() { |
|
1749 | - return $this->query('SettingsManager'); |
|
1750 | - } |
|
1751 | - |
|
1752 | - /** |
|
1753 | - * @return \OCP\Files\IAppData |
|
1754 | - */ |
|
1755 | - public function getAppDataDir($app) { |
|
1756 | - /** @var \OC\Files\AppData\Factory $factory */ |
|
1757 | - $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1758 | - return $factory->get($app); |
|
1759 | - } |
|
1760 | - |
|
1761 | - /** |
|
1762 | - * @return \OCP\Lockdown\ILockdownManager |
|
1763 | - */ |
|
1764 | - public function getLockdownManager() { |
|
1765 | - return $this->query('LockdownManager'); |
|
1766 | - } |
|
1767 | - |
|
1768 | - /** |
|
1769 | - * @return \OCP\Federation\ICloudIdManager |
|
1770 | - */ |
|
1771 | - public function getCloudIdManager() { |
|
1772 | - return $this->query(ICloudIdManager::class); |
|
1773 | - } |
|
852 | + $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
|
853 | + if (isset($prefixes['OCA\\Theming\\'])) { |
|
854 | + $classExists = true; |
|
855 | + } else { |
|
856 | + $classExists = false; |
|
857 | + } |
|
858 | + |
|
859 | + if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
|
860 | + return new ThemingDefaults( |
|
861 | + $c->getConfig(), |
|
862 | + $c->getL10N('theming'), |
|
863 | + $c->getURLGenerator(), |
|
864 | + new \OC_Defaults(), |
|
865 | + $c->getAppDataDir('theming'), |
|
866 | + $c->getMemCacheFactory(), |
|
867 | + new Util($c->getConfig(), $this->getRootFolder(), $this->getAppManager()) |
|
868 | + ); |
|
869 | + } |
|
870 | + return new \OC_Defaults(); |
|
871 | + }); |
|
872 | + $this->registerService(SCSSCacher::class, function(Server $c) { |
|
873 | + /** @var Factory $cacheFactory */ |
|
874 | + $cacheFactory = $c->query(Factory::class); |
|
875 | + return new SCSSCacher( |
|
876 | + $c->getLogger(), |
|
877 | + $c->query(\OC\Files\AppData\Factory::class), |
|
878 | + $c->getURLGenerator(), |
|
879 | + $c->getConfig(), |
|
880 | + $c->getThemingDefaults(), |
|
881 | + \OC::$SERVERROOT, |
|
882 | + $cacheFactory->createLocal('SCSS') |
|
883 | + ); |
|
884 | + }); |
|
885 | + $this->registerService(EventDispatcher::class, function () { |
|
886 | + return new EventDispatcher(); |
|
887 | + }); |
|
888 | + $this->registerAlias('EventDispatcher', EventDispatcher::class); |
|
889 | + $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
|
890 | + |
|
891 | + $this->registerService('CryptoWrapper', function (Server $c) { |
|
892 | + // FIXME: Instantiiated here due to cyclic dependency |
|
893 | + $request = new Request( |
|
894 | + [ |
|
895 | + 'get' => $_GET, |
|
896 | + 'post' => $_POST, |
|
897 | + 'files' => $_FILES, |
|
898 | + 'server' => $_SERVER, |
|
899 | + 'env' => $_ENV, |
|
900 | + 'cookies' => $_COOKIE, |
|
901 | + 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
|
902 | + ? $_SERVER['REQUEST_METHOD'] |
|
903 | + : null, |
|
904 | + ], |
|
905 | + $c->getSecureRandom(), |
|
906 | + $c->getConfig() |
|
907 | + ); |
|
908 | + |
|
909 | + return new CryptoWrapper( |
|
910 | + $c->getConfig(), |
|
911 | + $c->getCrypto(), |
|
912 | + $c->getSecureRandom(), |
|
913 | + $request |
|
914 | + ); |
|
915 | + }); |
|
916 | + $this->registerService('CsrfTokenManager', function (Server $c) { |
|
917 | + $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
|
918 | + |
|
919 | + return new CsrfTokenManager( |
|
920 | + $tokenGenerator, |
|
921 | + $c->query(SessionStorage::class) |
|
922 | + ); |
|
923 | + }); |
|
924 | + $this->registerService(SessionStorage::class, function (Server $c) { |
|
925 | + return new SessionStorage($c->getSession()); |
|
926 | + }); |
|
927 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
928 | + return new ContentSecurityPolicyManager(); |
|
929 | + }); |
|
930 | + $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
|
931 | + |
|
932 | + $this->registerService('ContentSecurityPolicyNonceManager', function(Server $c) { |
|
933 | + return new ContentSecurityPolicyNonceManager( |
|
934 | + $c->getCsrfTokenManager(), |
|
935 | + $c->getRequest() |
|
936 | + ); |
|
937 | + }); |
|
938 | + |
|
939 | + $this->registerService(\OCP\Share\IManager::class, function(Server $c) { |
|
940 | + $config = $c->getConfig(); |
|
941 | + $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
|
942 | + /** @var \OCP\Share\IProviderFactory $factory */ |
|
943 | + $factory = new $factoryClass($this); |
|
944 | + |
|
945 | + $manager = new \OC\Share20\Manager( |
|
946 | + $c->getLogger(), |
|
947 | + $c->getConfig(), |
|
948 | + $c->getSecureRandom(), |
|
949 | + $c->getHasher(), |
|
950 | + $c->getMountManager(), |
|
951 | + $c->getGroupManager(), |
|
952 | + $c->getL10N('core'), |
|
953 | + $factory, |
|
954 | + $c->getUserManager(), |
|
955 | + $c->getLazyRootFolder(), |
|
956 | + $c->getEventDispatcher() |
|
957 | + ); |
|
958 | + |
|
959 | + return $manager; |
|
960 | + }); |
|
961 | + $this->registerAlias('ShareManager', \OCP\Share\IManager::class); |
|
962 | + |
|
963 | + $this->registerService('SettingsManager', function(Server $c) { |
|
964 | + $manager = new \OC\Settings\Manager( |
|
965 | + $c->getLogger(), |
|
966 | + $c->getDatabaseConnection(), |
|
967 | + $c->getL10N('lib'), |
|
968 | + $c->getConfig(), |
|
969 | + $c->getEncryptionManager(), |
|
970 | + $c->getUserManager(), |
|
971 | + $c->getLockingProvider(), |
|
972 | + $c->getRequest(), |
|
973 | + new \OC\Settings\Mapper($c->getDatabaseConnection()), |
|
974 | + $c->getURLGenerator() |
|
975 | + ); |
|
976 | + return $manager; |
|
977 | + }); |
|
978 | + $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
979 | + return new \OC\Files\AppData\Factory( |
|
980 | + $c->getRootFolder(), |
|
981 | + $c->getSystemConfig() |
|
982 | + ); |
|
983 | + }); |
|
984 | + |
|
985 | + $this->registerService('LockdownManager', function (Server $c) { |
|
986 | + return new LockdownManager(function() use ($c) { |
|
987 | + return $c->getSession(); |
|
988 | + }); |
|
989 | + }); |
|
990 | + |
|
991 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
992 | + return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
|
993 | + }); |
|
994 | + |
|
995 | + $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
996 | + return new CloudIdManager(); |
|
997 | + }); |
|
998 | + |
|
999 | + /* To trick DI since we don't extend the DIContainer here */ |
|
1000 | + $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
1001 | + return new CleanPreviewsBackgroundJob( |
|
1002 | + $c->getRootFolder(), |
|
1003 | + $c->getLogger(), |
|
1004 | + $c->getJobList(), |
|
1005 | + new TimeFactory() |
|
1006 | + ); |
|
1007 | + }); |
|
1008 | + |
|
1009 | + $this->registerAlias(\OCP\AppFramework\Utility\IControllerMethodReflector::class, \OC\AppFramework\Utility\ControllerMethodReflector::class); |
|
1010 | + $this->registerAlias('ControllerMethodReflector', \OCP\AppFramework\Utility\IControllerMethodReflector::class); |
|
1011 | + |
|
1012 | + $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
|
1013 | + $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
|
1014 | + |
|
1015 | + $this->registerService(Defaults::class, function (Server $c) { |
|
1016 | + return new Defaults( |
|
1017 | + $c->getThemingDefaults() |
|
1018 | + ); |
|
1019 | + }); |
|
1020 | + $this->registerAlias('Defaults', \OCP\Defaults::class); |
|
1021 | + |
|
1022 | + $this->registerService(\OCP\ISession::class, function(SimpleContainer $c) { |
|
1023 | + return $c->query(\OCP\IUserSession::class)->getSession(); |
|
1024 | + }); |
|
1025 | + |
|
1026 | + $this->registerService(IShareHelper::class, function(Server $c) { |
|
1027 | + return new ShareHelper( |
|
1028 | + $c->query(\OCP\Share\IManager::class) |
|
1029 | + ); |
|
1030 | + }); |
|
1031 | + } |
|
1032 | + |
|
1033 | + /** |
|
1034 | + * @return \OCP\Contacts\IManager |
|
1035 | + */ |
|
1036 | + public function getContactsManager() { |
|
1037 | + return $this->query('ContactsManager'); |
|
1038 | + } |
|
1039 | + |
|
1040 | + /** |
|
1041 | + * @return \OC\Encryption\Manager |
|
1042 | + */ |
|
1043 | + public function getEncryptionManager() { |
|
1044 | + return $this->query('EncryptionManager'); |
|
1045 | + } |
|
1046 | + |
|
1047 | + /** |
|
1048 | + * @return \OC\Encryption\File |
|
1049 | + */ |
|
1050 | + public function getEncryptionFilesHelper() { |
|
1051 | + return $this->query('EncryptionFileHelper'); |
|
1052 | + } |
|
1053 | + |
|
1054 | + /** |
|
1055 | + * @return \OCP\Encryption\Keys\IStorage |
|
1056 | + */ |
|
1057 | + public function getEncryptionKeyStorage() { |
|
1058 | + return $this->query('EncryptionKeyStorage'); |
|
1059 | + } |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * The current request object holding all information about the request |
|
1063 | + * currently being processed is returned from this method. |
|
1064 | + * In case the current execution was not initiated by a web request null is returned |
|
1065 | + * |
|
1066 | + * @return \OCP\IRequest |
|
1067 | + */ |
|
1068 | + public function getRequest() { |
|
1069 | + return $this->query('Request'); |
|
1070 | + } |
|
1071 | + |
|
1072 | + /** |
|
1073 | + * Returns the preview manager which can create preview images for a given file |
|
1074 | + * |
|
1075 | + * @return \OCP\IPreview |
|
1076 | + */ |
|
1077 | + public function getPreviewManager() { |
|
1078 | + return $this->query('PreviewManager'); |
|
1079 | + } |
|
1080 | + |
|
1081 | + /** |
|
1082 | + * Returns the tag manager which can get and set tags for different object types |
|
1083 | + * |
|
1084 | + * @see \OCP\ITagManager::load() |
|
1085 | + * @return \OCP\ITagManager |
|
1086 | + */ |
|
1087 | + public function getTagManager() { |
|
1088 | + return $this->query('TagManager'); |
|
1089 | + } |
|
1090 | + |
|
1091 | + /** |
|
1092 | + * Returns the system-tag manager |
|
1093 | + * |
|
1094 | + * @return \OCP\SystemTag\ISystemTagManager |
|
1095 | + * |
|
1096 | + * @since 9.0.0 |
|
1097 | + */ |
|
1098 | + public function getSystemTagManager() { |
|
1099 | + return $this->query('SystemTagManager'); |
|
1100 | + } |
|
1101 | + |
|
1102 | + /** |
|
1103 | + * Returns the system-tag object mapper |
|
1104 | + * |
|
1105 | + * @return \OCP\SystemTag\ISystemTagObjectMapper |
|
1106 | + * |
|
1107 | + * @since 9.0.0 |
|
1108 | + */ |
|
1109 | + public function getSystemTagObjectMapper() { |
|
1110 | + return $this->query('SystemTagObjectMapper'); |
|
1111 | + } |
|
1112 | + |
|
1113 | + /** |
|
1114 | + * Returns the avatar manager, used for avatar functionality |
|
1115 | + * |
|
1116 | + * @return \OCP\IAvatarManager |
|
1117 | + */ |
|
1118 | + public function getAvatarManager() { |
|
1119 | + return $this->query('AvatarManager'); |
|
1120 | + } |
|
1121 | + |
|
1122 | + /** |
|
1123 | + * Returns the root folder of ownCloud's data directory |
|
1124 | + * |
|
1125 | + * @return \OCP\Files\IRootFolder |
|
1126 | + */ |
|
1127 | + public function getRootFolder() { |
|
1128 | + return $this->query('LazyRootFolder'); |
|
1129 | + } |
|
1130 | + |
|
1131 | + /** |
|
1132 | + * Returns the root folder of ownCloud's data directory |
|
1133 | + * This is the lazy variant so this gets only initialized once it |
|
1134 | + * is actually used. |
|
1135 | + * |
|
1136 | + * @return \OCP\Files\IRootFolder |
|
1137 | + */ |
|
1138 | + public function getLazyRootFolder() { |
|
1139 | + return $this->query('LazyRootFolder'); |
|
1140 | + } |
|
1141 | + |
|
1142 | + /** |
|
1143 | + * Returns a view to ownCloud's files folder |
|
1144 | + * |
|
1145 | + * @param string $userId user ID |
|
1146 | + * @return \OCP\Files\Folder|null |
|
1147 | + */ |
|
1148 | + public function getUserFolder($userId = null) { |
|
1149 | + if ($userId === null) { |
|
1150 | + $user = $this->getUserSession()->getUser(); |
|
1151 | + if (!$user) { |
|
1152 | + return null; |
|
1153 | + } |
|
1154 | + $userId = $user->getUID(); |
|
1155 | + } |
|
1156 | + $root = $this->getRootFolder(); |
|
1157 | + return $root->getUserFolder($userId); |
|
1158 | + } |
|
1159 | + |
|
1160 | + /** |
|
1161 | + * Returns an app-specific view in ownClouds data directory |
|
1162 | + * |
|
1163 | + * @return \OCP\Files\Folder |
|
1164 | + * @deprecated since 9.2.0 use IAppData |
|
1165 | + */ |
|
1166 | + public function getAppFolder() { |
|
1167 | + $dir = '/' . \OC_App::getCurrentApp(); |
|
1168 | + $root = $this->getRootFolder(); |
|
1169 | + if (!$root->nodeExists($dir)) { |
|
1170 | + $folder = $root->newFolder($dir); |
|
1171 | + } else { |
|
1172 | + $folder = $root->get($dir); |
|
1173 | + } |
|
1174 | + return $folder; |
|
1175 | + } |
|
1176 | + |
|
1177 | + /** |
|
1178 | + * @return \OC\User\Manager |
|
1179 | + */ |
|
1180 | + public function getUserManager() { |
|
1181 | + return $this->query('UserManager'); |
|
1182 | + } |
|
1183 | + |
|
1184 | + /** |
|
1185 | + * @return \OC\Group\Manager |
|
1186 | + */ |
|
1187 | + public function getGroupManager() { |
|
1188 | + return $this->query('GroupManager'); |
|
1189 | + } |
|
1190 | + |
|
1191 | + /** |
|
1192 | + * @return \OC\User\Session |
|
1193 | + */ |
|
1194 | + public function getUserSession() { |
|
1195 | + return $this->query('UserSession'); |
|
1196 | + } |
|
1197 | + |
|
1198 | + /** |
|
1199 | + * @return \OCP\ISession |
|
1200 | + */ |
|
1201 | + public function getSession() { |
|
1202 | + return $this->query('UserSession')->getSession(); |
|
1203 | + } |
|
1204 | + |
|
1205 | + /** |
|
1206 | + * @param \OCP\ISession $session |
|
1207 | + */ |
|
1208 | + public function setSession(\OCP\ISession $session) { |
|
1209 | + $this->query(SessionStorage::class)->setSession($session); |
|
1210 | + $this->query('UserSession')->setSession($session); |
|
1211 | + $this->query(Store::class)->setSession($session); |
|
1212 | + } |
|
1213 | + |
|
1214 | + /** |
|
1215 | + * @return \OC\Authentication\TwoFactorAuth\Manager |
|
1216 | + */ |
|
1217 | + public function getTwoFactorAuthManager() { |
|
1218 | + return $this->query('\OC\Authentication\TwoFactorAuth\Manager'); |
|
1219 | + } |
|
1220 | + |
|
1221 | + /** |
|
1222 | + * @return \OC\NavigationManager |
|
1223 | + */ |
|
1224 | + public function getNavigationManager() { |
|
1225 | + return $this->query('NavigationManager'); |
|
1226 | + } |
|
1227 | + |
|
1228 | + /** |
|
1229 | + * @return \OCP\IConfig |
|
1230 | + */ |
|
1231 | + public function getConfig() { |
|
1232 | + return $this->query('AllConfig'); |
|
1233 | + } |
|
1234 | + |
|
1235 | + /** |
|
1236 | + * @internal For internal use only |
|
1237 | + * @return \OC\SystemConfig |
|
1238 | + */ |
|
1239 | + public function getSystemConfig() { |
|
1240 | + return $this->query('SystemConfig'); |
|
1241 | + } |
|
1242 | + |
|
1243 | + /** |
|
1244 | + * Returns the app config manager |
|
1245 | + * |
|
1246 | + * @return \OCP\IAppConfig |
|
1247 | + */ |
|
1248 | + public function getAppConfig() { |
|
1249 | + return $this->query('AppConfig'); |
|
1250 | + } |
|
1251 | + |
|
1252 | + /** |
|
1253 | + * @return \OCP\L10N\IFactory |
|
1254 | + */ |
|
1255 | + public function getL10NFactory() { |
|
1256 | + return $this->query('L10NFactory'); |
|
1257 | + } |
|
1258 | + |
|
1259 | + /** |
|
1260 | + * get an L10N instance |
|
1261 | + * |
|
1262 | + * @param string $app appid |
|
1263 | + * @param string $lang |
|
1264 | + * @return IL10N |
|
1265 | + */ |
|
1266 | + public function getL10N($app, $lang = null) { |
|
1267 | + return $this->getL10NFactory()->get($app, $lang); |
|
1268 | + } |
|
1269 | + |
|
1270 | + /** |
|
1271 | + * @return \OCP\IURLGenerator |
|
1272 | + */ |
|
1273 | + public function getURLGenerator() { |
|
1274 | + return $this->query('URLGenerator'); |
|
1275 | + } |
|
1276 | + |
|
1277 | + /** |
|
1278 | + * @return \OCP\IHelper |
|
1279 | + */ |
|
1280 | + public function getHelper() { |
|
1281 | + return $this->query('AppHelper'); |
|
1282 | + } |
|
1283 | + |
|
1284 | + /** |
|
1285 | + * @return AppFetcher |
|
1286 | + */ |
|
1287 | + public function getAppFetcher() { |
|
1288 | + return $this->query('AppFetcher'); |
|
1289 | + } |
|
1290 | + |
|
1291 | + /** |
|
1292 | + * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
|
1293 | + * getMemCacheFactory() instead. |
|
1294 | + * |
|
1295 | + * @return \OCP\ICache |
|
1296 | + * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
|
1297 | + */ |
|
1298 | + public function getCache() { |
|
1299 | + return $this->query('UserCache'); |
|
1300 | + } |
|
1301 | + |
|
1302 | + /** |
|
1303 | + * Returns an \OCP\CacheFactory instance |
|
1304 | + * |
|
1305 | + * @return \OCP\ICacheFactory |
|
1306 | + */ |
|
1307 | + public function getMemCacheFactory() { |
|
1308 | + return $this->query('MemCacheFactory'); |
|
1309 | + } |
|
1310 | + |
|
1311 | + /** |
|
1312 | + * Returns an \OC\RedisFactory instance |
|
1313 | + * |
|
1314 | + * @return \OC\RedisFactory |
|
1315 | + */ |
|
1316 | + public function getGetRedisFactory() { |
|
1317 | + return $this->query('RedisFactory'); |
|
1318 | + } |
|
1319 | + |
|
1320 | + |
|
1321 | + /** |
|
1322 | + * Returns the current session |
|
1323 | + * |
|
1324 | + * @return \OCP\IDBConnection |
|
1325 | + */ |
|
1326 | + public function getDatabaseConnection() { |
|
1327 | + return $this->query('DatabaseConnection'); |
|
1328 | + } |
|
1329 | + |
|
1330 | + /** |
|
1331 | + * Returns the activity manager |
|
1332 | + * |
|
1333 | + * @return \OCP\Activity\IManager |
|
1334 | + */ |
|
1335 | + public function getActivityManager() { |
|
1336 | + return $this->query('ActivityManager'); |
|
1337 | + } |
|
1338 | + |
|
1339 | + /** |
|
1340 | + * Returns an job list for controlling background jobs |
|
1341 | + * |
|
1342 | + * @return \OCP\BackgroundJob\IJobList |
|
1343 | + */ |
|
1344 | + public function getJobList() { |
|
1345 | + return $this->query('JobList'); |
|
1346 | + } |
|
1347 | + |
|
1348 | + /** |
|
1349 | + * Returns a logger instance |
|
1350 | + * |
|
1351 | + * @return \OCP\ILogger |
|
1352 | + */ |
|
1353 | + public function getLogger() { |
|
1354 | + return $this->query('Logger'); |
|
1355 | + } |
|
1356 | + |
|
1357 | + /** |
|
1358 | + * Returns a router for generating and matching urls |
|
1359 | + * |
|
1360 | + * @return \OCP\Route\IRouter |
|
1361 | + */ |
|
1362 | + public function getRouter() { |
|
1363 | + return $this->query('Router'); |
|
1364 | + } |
|
1365 | + |
|
1366 | + /** |
|
1367 | + * Returns a search instance |
|
1368 | + * |
|
1369 | + * @return \OCP\ISearch |
|
1370 | + */ |
|
1371 | + public function getSearch() { |
|
1372 | + return $this->query('Search'); |
|
1373 | + } |
|
1374 | + |
|
1375 | + /** |
|
1376 | + * Returns a SecureRandom instance |
|
1377 | + * |
|
1378 | + * @return \OCP\Security\ISecureRandom |
|
1379 | + */ |
|
1380 | + public function getSecureRandom() { |
|
1381 | + return $this->query('SecureRandom'); |
|
1382 | + } |
|
1383 | + |
|
1384 | + /** |
|
1385 | + * Returns a Crypto instance |
|
1386 | + * |
|
1387 | + * @return \OCP\Security\ICrypto |
|
1388 | + */ |
|
1389 | + public function getCrypto() { |
|
1390 | + return $this->query('Crypto'); |
|
1391 | + } |
|
1392 | + |
|
1393 | + /** |
|
1394 | + * Returns a Hasher instance |
|
1395 | + * |
|
1396 | + * @return \OCP\Security\IHasher |
|
1397 | + */ |
|
1398 | + public function getHasher() { |
|
1399 | + return $this->query('Hasher'); |
|
1400 | + } |
|
1401 | + |
|
1402 | + /** |
|
1403 | + * Returns a CredentialsManager instance |
|
1404 | + * |
|
1405 | + * @return \OCP\Security\ICredentialsManager |
|
1406 | + */ |
|
1407 | + public function getCredentialsManager() { |
|
1408 | + return $this->query('CredentialsManager'); |
|
1409 | + } |
|
1410 | + |
|
1411 | + /** |
|
1412 | + * Returns an instance of the HTTP helper class |
|
1413 | + * |
|
1414 | + * @deprecated Use getHTTPClientService() |
|
1415 | + * @return \OC\HTTPHelper |
|
1416 | + */ |
|
1417 | + public function getHTTPHelper() { |
|
1418 | + return $this->query('HTTPHelper'); |
|
1419 | + } |
|
1420 | + |
|
1421 | + /** |
|
1422 | + * Get the certificate manager for the user |
|
1423 | + * |
|
1424 | + * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
|
1425 | + * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
|
1426 | + */ |
|
1427 | + public function getCertificateManager($userId = '') { |
|
1428 | + if ($userId === '') { |
|
1429 | + $userSession = $this->getUserSession(); |
|
1430 | + $user = $userSession->getUser(); |
|
1431 | + if (is_null($user)) { |
|
1432 | + return null; |
|
1433 | + } |
|
1434 | + $userId = $user->getUID(); |
|
1435 | + } |
|
1436 | + return new CertificateManager($userId, new View(), $this->getConfig(), $this->getLogger()); |
|
1437 | + } |
|
1438 | + |
|
1439 | + /** |
|
1440 | + * Returns an instance of the HTTP client service |
|
1441 | + * |
|
1442 | + * @return \OCP\Http\Client\IClientService |
|
1443 | + */ |
|
1444 | + public function getHTTPClientService() { |
|
1445 | + return $this->query('HttpClientService'); |
|
1446 | + } |
|
1447 | + |
|
1448 | + /** |
|
1449 | + * Create a new event source |
|
1450 | + * |
|
1451 | + * @return \OCP\IEventSource |
|
1452 | + */ |
|
1453 | + public function createEventSource() { |
|
1454 | + return new \OC_EventSource(); |
|
1455 | + } |
|
1456 | + |
|
1457 | + /** |
|
1458 | + * Get the active event logger |
|
1459 | + * |
|
1460 | + * The returned logger only logs data when debug mode is enabled |
|
1461 | + * |
|
1462 | + * @return \OCP\Diagnostics\IEventLogger |
|
1463 | + */ |
|
1464 | + public function getEventLogger() { |
|
1465 | + return $this->query('EventLogger'); |
|
1466 | + } |
|
1467 | + |
|
1468 | + /** |
|
1469 | + * Get the active query logger |
|
1470 | + * |
|
1471 | + * The returned logger only logs data when debug mode is enabled |
|
1472 | + * |
|
1473 | + * @return \OCP\Diagnostics\IQueryLogger |
|
1474 | + */ |
|
1475 | + public function getQueryLogger() { |
|
1476 | + return $this->query('QueryLogger'); |
|
1477 | + } |
|
1478 | + |
|
1479 | + /** |
|
1480 | + * Get the manager for temporary files and folders |
|
1481 | + * |
|
1482 | + * @return \OCP\ITempManager |
|
1483 | + */ |
|
1484 | + public function getTempManager() { |
|
1485 | + return $this->query('TempManager'); |
|
1486 | + } |
|
1487 | + |
|
1488 | + /** |
|
1489 | + * Get the app manager |
|
1490 | + * |
|
1491 | + * @return \OCP\App\IAppManager |
|
1492 | + */ |
|
1493 | + public function getAppManager() { |
|
1494 | + return $this->query('AppManager'); |
|
1495 | + } |
|
1496 | + |
|
1497 | + /** |
|
1498 | + * Creates a new mailer |
|
1499 | + * |
|
1500 | + * @return \OCP\Mail\IMailer |
|
1501 | + */ |
|
1502 | + public function getMailer() { |
|
1503 | + return $this->query('Mailer'); |
|
1504 | + } |
|
1505 | + |
|
1506 | + /** |
|
1507 | + * Get the webroot |
|
1508 | + * |
|
1509 | + * @return string |
|
1510 | + */ |
|
1511 | + public function getWebRoot() { |
|
1512 | + return $this->webRoot; |
|
1513 | + } |
|
1514 | + |
|
1515 | + /** |
|
1516 | + * @return \OC\OCSClient |
|
1517 | + */ |
|
1518 | + public function getOcsClient() { |
|
1519 | + return $this->query('OcsClient'); |
|
1520 | + } |
|
1521 | + |
|
1522 | + /** |
|
1523 | + * @return \OCP\IDateTimeZone |
|
1524 | + */ |
|
1525 | + public function getDateTimeZone() { |
|
1526 | + return $this->query('DateTimeZone'); |
|
1527 | + } |
|
1528 | + |
|
1529 | + /** |
|
1530 | + * @return \OCP\IDateTimeFormatter |
|
1531 | + */ |
|
1532 | + public function getDateTimeFormatter() { |
|
1533 | + return $this->query('DateTimeFormatter'); |
|
1534 | + } |
|
1535 | + |
|
1536 | + /** |
|
1537 | + * @return \OCP\Files\Config\IMountProviderCollection |
|
1538 | + */ |
|
1539 | + public function getMountProviderCollection() { |
|
1540 | + return $this->query('MountConfigManager'); |
|
1541 | + } |
|
1542 | + |
|
1543 | + /** |
|
1544 | + * Get the IniWrapper |
|
1545 | + * |
|
1546 | + * @return IniGetWrapper |
|
1547 | + */ |
|
1548 | + public function getIniWrapper() { |
|
1549 | + return $this->query('IniWrapper'); |
|
1550 | + } |
|
1551 | + |
|
1552 | + /** |
|
1553 | + * @return \OCP\Command\IBus |
|
1554 | + */ |
|
1555 | + public function getCommandBus() { |
|
1556 | + return $this->query('AsyncCommandBus'); |
|
1557 | + } |
|
1558 | + |
|
1559 | + /** |
|
1560 | + * Get the trusted domain helper |
|
1561 | + * |
|
1562 | + * @return TrustedDomainHelper |
|
1563 | + */ |
|
1564 | + public function getTrustedDomainHelper() { |
|
1565 | + return $this->query('TrustedDomainHelper'); |
|
1566 | + } |
|
1567 | + |
|
1568 | + /** |
|
1569 | + * Get the locking provider |
|
1570 | + * |
|
1571 | + * @return \OCP\Lock\ILockingProvider |
|
1572 | + * @since 8.1.0 |
|
1573 | + */ |
|
1574 | + public function getLockingProvider() { |
|
1575 | + return $this->query('LockingProvider'); |
|
1576 | + } |
|
1577 | + |
|
1578 | + /** |
|
1579 | + * @return \OCP\Files\Mount\IMountManager |
|
1580 | + **/ |
|
1581 | + function getMountManager() { |
|
1582 | + return $this->query('MountManager'); |
|
1583 | + } |
|
1584 | + |
|
1585 | + /** @return \OCP\Files\Config\IUserMountCache */ |
|
1586 | + function getUserMountCache() { |
|
1587 | + return $this->query('UserMountCache'); |
|
1588 | + } |
|
1589 | + |
|
1590 | + /** |
|
1591 | + * Get the MimeTypeDetector |
|
1592 | + * |
|
1593 | + * @return \OCP\Files\IMimeTypeDetector |
|
1594 | + */ |
|
1595 | + public function getMimeTypeDetector() { |
|
1596 | + return $this->query('MimeTypeDetector'); |
|
1597 | + } |
|
1598 | + |
|
1599 | + /** |
|
1600 | + * Get the MimeTypeLoader |
|
1601 | + * |
|
1602 | + * @return \OCP\Files\IMimeTypeLoader |
|
1603 | + */ |
|
1604 | + public function getMimeTypeLoader() { |
|
1605 | + return $this->query('MimeTypeLoader'); |
|
1606 | + } |
|
1607 | + |
|
1608 | + /** |
|
1609 | + * Get the manager of all the capabilities |
|
1610 | + * |
|
1611 | + * @return \OC\CapabilitiesManager |
|
1612 | + */ |
|
1613 | + public function getCapabilitiesManager() { |
|
1614 | + return $this->query('CapabilitiesManager'); |
|
1615 | + } |
|
1616 | + |
|
1617 | + /** |
|
1618 | + * Get the EventDispatcher |
|
1619 | + * |
|
1620 | + * @return EventDispatcherInterface |
|
1621 | + * @since 8.2.0 |
|
1622 | + */ |
|
1623 | + public function getEventDispatcher() { |
|
1624 | + return $this->query('EventDispatcher'); |
|
1625 | + } |
|
1626 | + |
|
1627 | + /** |
|
1628 | + * Get the Notification Manager |
|
1629 | + * |
|
1630 | + * @return \OCP\Notification\IManager |
|
1631 | + * @since 8.2.0 |
|
1632 | + */ |
|
1633 | + public function getNotificationManager() { |
|
1634 | + return $this->query('NotificationManager'); |
|
1635 | + } |
|
1636 | + |
|
1637 | + /** |
|
1638 | + * @return \OCP\Comments\ICommentsManager |
|
1639 | + */ |
|
1640 | + public function getCommentsManager() { |
|
1641 | + return $this->query('CommentsManager'); |
|
1642 | + } |
|
1643 | + |
|
1644 | + /** |
|
1645 | + * @return \OCA\Theming\ThemingDefaults |
|
1646 | + */ |
|
1647 | + public function getThemingDefaults() { |
|
1648 | + return $this->query('ThemingDefaults'); |
|
1649 | + } |
|
1650 | + |
|
1651 | + /** |
|
1652 | + * @return \OC\IntegrityCheck\Checker |
|
1653 | + */ |
|
1654 | + public function getIntegrityCodeChecker() { |
|
1655 | + return $this->query('IntegrityCodeChecker'); |
|
1656 | + } |
|
1657 | + |
|
1658 | + /** |
|
1659 | + * @return \OC\Session\CryptoWrapper |
|
1660 | + */ |
|
1661 | + public function getSessionCryptoWrapper() { |
|
1662 | + return $this->query('CryptoWrapper'); |
|
1663 | + } |
|
1664 | + |
|
1665 | + /** |
|
1666 | + * @return CsrfTokenManager |
|
1667 | + */ |
|
1668 | + public function getCsrfTokenManager() { |
|
1669 | + return $this->query('CsrfTokenManager'); |
|
1670 | + } |
|
1671 | + |
|
1672 | + /** |
|
1673 | + * @return Throttler |
|
1674 | + */ |
|
1675 | + public function getBruteForceThrottler() { |
|
1676 | + return $this->query('Throttler'); |
|
1677 | + } |
|
1678 | + |
|
1679 | + /** |
|
1680 | + * @return IContentSecurityPolicyManager |
|
1681 | + */ |
|
1682 | + public function getContentSecurityPolicyManager() { |
|
1683 | + return $this->query('ContentSecurityPolicyManager'); |
|
1684 | + } |
|
1685 | + |
|
1686 | + /** |
|
1687 | + * @return ContentSecurityPolicyNonceManager |
|
1688 | + */ |
|
1689 | + public function getContentSecurityPolicyNonceManager() { |
|
1690 | + return $this->query('ContentSecurityPolicyNonceManager'); |
|
1691 | + } |
|
1692 | + |
|
1693 | + /** |
|
1694 | + * Not a public API as of 8.2, wait for 9.0 |
|
1695 | + * |
|
1696 | + * @return \OCA\Files_External\Service\BackendService |
|
1697 | + */ |
|
1698 | + public function getStoragesBackendService() { |
|
1699 | + return $this->query('OCA\\Files_External\\Service\\BackendService'); |
|
1700 | + } |
|
1701 | + |
|
1702 | + /** |
|
1703 | + * Not a public API as of 8.2, wait for 9.0 |
|
1704 | + * |
|
1705 | + * @return \OCA\Files_External\Service\GlobalStoragesService |
|
1706 | + */ |
|
1707 | + public function getGlobalStoragesService() { |
|
1708 | + return $this->query('OCA\\Files_External\\Service\\GlobalStoragesService'); |
|
1709 | + } |
|
1710 | + |
|
1711 | + /** |
|
1712 | + * Not a public API as of 8.2, wait for 9.0 |
|
1713 | + * |
|
1714 | + * @return \OCA\Files_External\Service\UserGlobalStoragesService |
|
1715 | + */ |
|
1716 | + public function getUserGlobalStoragesService() { |
|
1717 | + return $this->query('OCA\\Files_External\\Service\\UserGlobalStoragesService'); |
|
1718 | + } |
|
1719 | + |
|
1720 | + /** |
|
1721 | + * Not a public API as of 8.2, wait for 9.0 |
|
1722 | + * |
|
1723 | + * @return \OCA\Files_External\Service\UserStoragesService |
|
1724 | + */ |
|
1725 | + public function getUserStoragesService() { |
|
1726 | + return $this->query('OCA\\Files_External\\Service\\UserStoragesService'); |
|
1727 | + } |
|
1728 | + |
|
1729 | + /** |
|
1730 | + * @return \OCP\Share\IManager |
|
1731 | + */ |
|
1732 | + public function getShareManager() { |
|
1733 | + return $this->query('ShareManager'); |
|
1734 | + } |
|
1735 | + |
|
1736 | + /** |
|
1737 | + * Returns the LDAP Provider |
|
1738 | + * |
|
1739 | + * @return \OCP\LDAP\ILDAPProvider |
|
1740 | + */ |
|
1741 | + public function getLDAPProvider() { |
|
1742 | + return $this->query('LDAPProvider'); |
|
1743 | + } |
|
1744 | + |
|
1745 | + /** |
|
1746 | + * @return \OCP\Settings\IManager |
|
1747 | + */ |
|
1748 | + public function getSettingsManager() { |
|
1749 | + return $this->query('SettingsManager'); |
|
1750 | + } |
|
1751 | + |
|
1752 | + /** |
|
1753 | + * @return \OCP\Files\IAppData |
|
1754 | + */ |
|
1755 | + public function getAppDataDir($app) { |
|
1756 | + /** @var \OC\Files\AppData\Factory $factory */ |
|
1757 | + $factory = $this->query(\OC\Files\AppData\Factory::class); |
|
1758 | + return $factory->get($app); |
|
1759 | + } |
|
1760 | + |
|
1761 | + /** |
|
1762 | + * @return \OCP\Lockdown\ILockdownManager |
|
1763 | + */ |
|
1764 | + public function getLockdownManager() { |
|
1765 | + return $this->query('LockdownManager'); |
|
1766 | + } |
|
1767 | + |
|
1768 | + /** |
|
1769 | + * @return \OCP\Federation\ICloudIdManager |
|
1770 | + */ |
|
1771 | + public function getCloudIdManager() { |
|
1772 | + return $this->query(ICloudIdManager::class); |
|
1773 | + } |
|
1774 | 1774 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | |
148 | 148 | |
149 | 149 | |
150 | - $this->registerService(\OCP\IPreview::class, function (Server $c) { |
|
150 | + $this->registerService(\OCP\IPreview::class, function(Server $c) { |
|
151 | 151 | return new PreviewManager( |
152 | 152 | $c->getConfig(), |
153 | 153 | $c->getRootFolder(), |
@@ -158,13 +158,13 @@ discard block |
||
158 | 158 | }); |
159 | 159 | $this->registerAlias('PreviewManager', \OCP\IPreview::class); |
160 | 160 | |
161 | - $this->registerService(\OC\Preview\Watcher::class, function (Server $c) { |
|
161 | + $this->registerService(\OC\Preview\Watcher::class, function(Server $c) { |
|
162 | 162 | return new \OC\Preview\Watcher( |
163 | 163 | $c->getAppDataDir('preview') |
164 | 164 | ); |
165 | 165 | }); |
166 | 166 | |
167 | - $this->registerService('EncryptionManager', function (Server $c) { |
|
167 | + $this->registerService('EncryptionManager', function(Server $c) { |
|
168 | 168 | $view = new View(); |
169 | 169 | $util = new Encryption\Util( |
170 | 170 | $view, |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | ); |
183 | 183 | }); |
184 | 184 | |
185 | - $this->registerService('EncryptionFileHelper', function (Server $c) { |
|
185 | + $this->registerService('EncryptionFileHelper', function(Server $c) { |
|
186 | 186 | $util = new Encryption\Util( |
187 | 187 | new View(), |
188 | 188 | $c->getUserManager(), |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | ); |
197 | 197 | }); |
198 | 198 | |
199 | - $this->registerService('EncryptionKeyStorage', function (Server $c) { |
|
199 | + $this->registerService('EncryptionKeyStorage', function(Server $c) { |
|
200 | 200 | $view = new View(); |
201 | 201 | $util = new Encryption\Util( |
202 | 202 | $view, |
@@ -207,32 +207,32 @@ discard block |
||
207 | 207 | |
208 | 208 | return new Encryption\Keys\Storage($view, $util); |
209 | 209 | }); |
210 | - $this->registerService('TagMapper', function (Server $c) { |
|
210 | + $this->registerService('TagMapper', function(Server $c) { |
|
211 | 211 | return new TagMapper($c->getDatabaseConnection()); |
212 | 212 | }); |
213 | 213 | |
214 | - $this->registerService(\OCP\ITagManager::class, function (Server $c) { |
|
214 | + $this->registerService(\OCP\ITagManager::class, function(Server $c) { |
|
215 | 215 | $tagMapper = $c->query('TagMapper'); |
216 | 216 | return new TagManager($tagMapper, $c->getUserSession()); |
217 | 217 | }); |
218 | 218 | $this->registerAlias('TagManager', \OCP\ITagManager::class); |
219 | 219 | |
220 | - $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
220 | + $this->registerService('SystemTagManagerFactory', function(Server $c) { |
|
221 | 221 | $config = $c->getConfig(); |
222 | 222 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
223 | 223 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
224 | 224 | $factory = new $factoryClass($this); |
225 | 225 | return $factory; |
226 | 226 | }); |
227 | - $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function (Server $c) { |
|
227 | + $this->registerService(\OCP\SystemTag\ISystemTagManager::class, function(Server $c) { |
|
228 | 228 | return $c->query('SystemTagManagerFactory')->getManager(); |
229 | 229 | }); |
230 | 230 | $this->registerAlias('SystemTagManager', \OCP\SystemTag\ISystemTagManager::class); |
231 | 231 | |
232 | - $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function (Server $c) { |
|
232 | + $this->registerService(\OCP\SystemTag\ISystemTagObjectMapper::class, function(Server $c) { |
|
233 | 233 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
234 | 234 | }); |
235 | - $this->registerService('RootFolder', function (Server $c) { |
|
235 | + $this->registerService('RootFolder', function(Server $c) { |
|
236 | 236 | $manager = \OC\Files\Filesystem::getMountManager(null); |
237 | 237 | $view = new View(); |
238 | 238 | $root = new Root( |
@@ -260,30 +260,30 @@ discard block |
||
260 | 260 | }); |
261 | 261 | $this->registerAlias('LazyRootFolder', \OCP\Files\IRootFolder::class); |
262 | 262 | |
263 | - $this->registerService(\OCP\IUserManager::class, function (Server $c) { |
|
263 | + $this->registerService(\OCP\IUserManager::class, function(Server $c) { |
|
264 | 264 | $config = $c->getConfig(); |
265 | 265 | return new \OC\User\Manager($config); |
266 | 266 | }); |
267 | 267 | $this->registerAlias('UserManager', \OCP\IUserManager::class); |
268 | 268 | |
269 | - $this->registerService(\OCP\IGroupManager::class, function (Server $c) { |
|
269 | + $this->registerService(\OCP\IGroupManager::class, function(Server $c) { |
|
270 | 270 | $groupManager = new \OC\Group\Manager($this->getUserManager(), $this->getLogger()); |
271 | - $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
|
271 | + $groupManager->listen('\OC\Group', 'preCreate', function($gid) { |
|
272 | 272 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
273 | 273 | }); |
274 | - $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
|
274 | + $groupManager->listen('\OC\Group', 'postCreate', function(\OC\Group\Group $gid) { |
|
275 | 275 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
276 | 276 | }); |
277 | - $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
|
277 | + $groupManager->listen('\OC\Group', 'preDelete', function(\OC\Group\Group $group) { |
|
278 | 278 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
279 | 279 | }); |
280 | - $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
|
280 | + $groupManager->listen('\OC\Group', 'postDelete', function(\OC\Group\Group $group) { |
|
281 | 281 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
282 | 282 | }); |
283 | - $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
283 | + $groupManager->listen('\OC\Group', 'preAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
284 | 284 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
285 | 285 | }); |
286 | - $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
|
286 | + $groupManager->listen('\OC\Group', 'postAddUser', function(\OC\Group\Group $group, \OC\User\User $user) { |
|
287 | 287 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
288 | 288 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
289 | 289 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
@@ -303,11 +303,11 @@ discard block |
||
303 | 303 | return new Store($session, $logger, $tokenProvider); |
304 | 304 | }); |
305 | 305 | $this->registerAlias(IStore::class, Store::class); |
306 | - $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
|
306 | + $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function(Server $c) { |
|
307 | 307 | $dbConnection = $c->getDatabaseConnection(); |
308 | 308 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
309 | 309 | }); |
310 | - $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
|
310 | + $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function(Server $c) { |
|
311 | 311 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
312 | 312 | $crypto = $c->getCrypto(); |
313 | 313 | $config = $c->getConfig(); |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | }); |
318 | 318 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
319 | 319 | |
320 | - $this->registerService(\OCP\IUserSession::class, function (Server $c) { |
|
320 | + $this->registerService(\OCP\IUserSession::class, function(Server $c) { |
|
321 | 321 | $manager = $c->getUserManager(); |
322 | 322 | $session = new \OC\Session\Memory(''); |
323 | 323 | $timeFactory = new TimeFactory(); |
@@ -330,40 +330,40 @@ discard block |
||
330 | 330 | } |
331 | 331 | |
332 | 332 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig(), $c->getSecureRandom(), $c->getLockdownManager()); |
333 | - $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
|
333 | + $userSession->listen('\OC\User', 'preCreateUser', function($uid, $password) { |
|
334 | 334 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
335 | 335 | }); |
336 | - $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
|
336 | + $userSession->listen('\OC\User', 'postCreateUser', function($user, $password) { |
|
337 | 337 | /** @var $user \OC\User\User */ |
338 | 338 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
339 | 339 | }); |
340 | - $userSession->listen('\OC\User', 'preDelete', function ($user) { |
|
340 | + $userSession->listen('\OC\User', 'preDelete', function($user) { |
|
341 | 341 | /** @var $user \OC\User\User */ |
342 | 342 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
343 | 343 | }); |
344 | - $userSession->listen('\OC\User', 'postDelete', function ($user) { |
|
344 | + $userSession->listen('\OC\User', 'postDelete', function($user) { |
|
345 | 345 | /** @var $user \OC\User\User */ |
346 | 346 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
347 | 347 | }); |
348 | - $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
348 | + $userSession->listen('\OC\User', 'preSetPassword', function($user, $password, $recoveryPassword) { |
|
349 | 349 | /** @var $user \OC\User\User */ |
350 | 350 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
351 | 351 | }); |
352 | - $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
352 | + $userSession->listen('\OC\User', 'postSetPassword', function($user, $password, $recoveryPassword) { |
|
353 | 353 | /** @var $user \OC\User\User */ |
354 | 354 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
355 | 355 | }); |
356 | - $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
|
356 | + $userSession->listen('\OC\User', 'preLogin', function($uid, $password) { |
|
357 | 357 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
358 | 358 | }); |
359 | - $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
|
359 | + $userSession->listen('\OC\User', 'postLogin', function($user, $password) { |
|
360 | 360 | /** @var $user \OC\User\User */ |
361 | 361 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
362 | 362 | }); |
363 | - $userSession->listen('\OC\User', 'logout', function () { |
|
363 | + $userSession->listen('\OC\User', 'logout', function() { |
|
364 | 364 | \OC_Hook::emit('OC_User', 'logout', array()); |
365 | 365 | }); |
366 | - $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) { |
|
366 | + $userSession->listen('\OC\User', 'changeUser', function($user, $feature, $value, $oldValue) { |
|
367 | 367 | /** @var $user \OC\User\User */ |
368 | 368 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue)); |
369 | 369 | }); |
@@ -371,14 +371,14 @@ discard block |
||
371 | 371 | }); |
372 | 372 | $this->registerAlias('UserSession', \OCP\IUserSession::class); |
373 | 373 | |
374 | - $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { |
|
374 | + $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function(Server $c) { |
|
375 | 375 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); |
376 | 376 | }); |
377 | 377 | |
378 | 378 | $this->registerAlias(\OCP\INavigationManager::class, \OC\NavigationManager::class); |
379 | 379 | $this->registerAlias('NavigationManager', \OCP\INavigationManager::class); |
380 | 380 | |
381 | - $this->registerService(\OC\AllConfig::class, function (Server $c) { |
|
381 | + $this->registerService(\OC\AllConfig::class, function(Server $c) { |
|
382 | 382 | return new \OC\AllConfig( |
383 | 383 | $c->getSystemConfig() |
384 | 384 | ); |
@@ -386,17 +386,17 @@ discard block |
||
386 | 386 | $this->registerAlias('AllConfig', \OC\AllConfig::class); |
387 | 387 | $this->registerAlias(\OCP\IConfig::class, \OC\AllConfig::class); |
388 | 388 | |
389 | - $this->registerService('SystemConfig', function ($c) use ($config) { |
|
389 | + $this->registerService('SystemConfig', function($c) use ($config) { |
|
390 | 390 | return new \OC\SystemConfig($config); |
391 | 391 | }); |
392 | 392 | |
393 | - $this->registerService(\OC\AppConfig::class, function (Server $c) { |
|
393 | + $this->registerService(\OC\AppConfig::class, function(Server $c) { |
|
394 | 394 | return new \OC\AppConfig($c->getDatabaseConnection()); |
395 | 395 | }); |
396 | 396 | $this->registerAlias('AppConfig', \OC\AppConfig::class); |
397 | 397 | $this->registerAlias(\OCP\IAppConfig::class, \OC\AppConfig::class); |
398 | 398 | |
399 | - $this->registerService(\OCP\L10N\IFactory::class, function (Server $c) { |
|
399 | + $this->registerService(\OCP\L10N\IFactory::class, function(Server $c) { |
|
400 | 400 | return new \OC\L10N\Factory( |
401 | 401 | $c->getConfig(), |
402 | 402 | $c->getRequest(), |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | }); |
407 | 407 | $this->registerAlias('L10NFactory', \OCP\L10N\IFactory::class); |
408 | 408 | |
409 | - $this->registerService(\OCP\IURLGenerator::class, function (Server $c) { |
|
409 | + $this->registerService(\OCP\IURLGenerator::class, function(Server $c) { |
|
410 | 410 | $config = $c->getConfig(); |
411 | 411 | $cacheFactory = $c->getMemCacheFactory(); |
412 | 412 | return new \OC\URLGenerator( |
@@ -416,10 +416,10 @@ discard block |
||
416 | 416 | }); |
417 | 417 | $this->registerAlias('URLGenerator', \OCP\IURLGenerator::class); |
418 | 418 | |
419 | - $this->registerService('AppHelper', function ($c) { |
|
419 | + $this->registerService('AppHelper', function($c) { |
|
420 | 420 | return new \OC\AppHelper(); |
421 | 421 | }); |
422 | - $this->registerService('AppFetcher', function ($c) { |
|
422 | + $this->registerService('AppFetcher', function($c) { |
|
423 | 423 | return new AppFetcher( |
424 | 424 | $this->getAppDataDir('appstore'), |
425 | 425 | $this->getHTTPClientService(), |
@@ -427,7 +427,7 @@ discard block |
||
427 | 427 | $this->getConfig() |
428 | 428 | ); |
429 | 429 | }); |
430 | - $this->registerService('CategoryFetcher', function ($c) { |
|
430 | + $this->registerService('CategoryFetcher', function($c) { |
|
431 | 431 | return new CategoryFetcher( |
432 | 432 | $this->getAppDataDir('appstore'), |
433 | 433 | $this->getHTTPClientService(), |
@@ -436,21 +436,21 @@ discard block |
||
436 | 436 | ); |
437 | 437 | }); |
438 | 438 | |
439 | - $this->registerService(\OCP\ICache::class, function ($c) { |
|
439 | + $this->registerService(\OCP\ICache::class, function($c) { |
|
440 | 440 | return new Cache\File(); |
441 | 441 | }); |
442 | 442 | $this->registerAlias('UserCache', \OCP\ICache::class); |
443 | 443 | |
444 | - $this->registerService(Factory::class, function (Server $c) { |
|
444 | + $this->registerService(Factory::class, function(Server $c) { |
|
445 | 445 | $config = $c->getConfig(); |
446 | 446 | |
447 | 447 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
448 | 448 | $v = \OC_App::getAppVersions(); |
449 | - $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
|
449 | + $v['core'] = md5(file_get_contents(\OC::$SERVERROOT.'/version.php')); |
|
450 | 450 | $version = implode(',', $v); |
451 | 451 | $instanceId = \OC_Util::getInstanceId(); |
452 | 452 | $path = \OC::$SERVERROOT; |
453 | - $prefix = md5($instanceId . '-' . $version . '-' . $path . '-' . \OC::$WEBROOT); |
|
453 | + $prefix = md5($instanceId.'-'.$version.'-'.$path.'-'.\OC::$WEBROOT); |
|
454 | 454 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
455 | 455 | $config->getSystemValue('memcache.local', null), |
456 | 456 | $config->getSystemValue('memcache.distributed', null), |
@@ -467,12 +467,12 @@ discard block |
||
467 | 467 | $this->registerAlias('MemCacheFactory', Factory::class); |
468 | 468 | $this->registerAlias(ICacheFactory::class, Factory::class); |
469 | 469 | |
470 | - $this->registerService('RedisFactory', function (Server $c) { |
|
470 | + $this->registerService('RedisFactory', function(Server $c) { |
|
471 | 471 | $systemConfig = $c->getSystemConfig(); |
472 | 472 | return new RedisFactory($systemConfig); |
473 | 473 | }); |
474 | 474 | |
475 | - $this->registerService(\OCP\Activity\IManager::class, function (Server $c) { |
|
475 | + $this->registerService(\OCP\Activity\IManager::class, function(Server $c) { |
|
476 | 476 | return new \OC\Activity\Manager( |
477 | 477 | $c->getRequest(), |
478 | 478 | $c->getUserSession(), |
@@ -482,14 +482,14 @@ discard block |
||
482 | 482 | }); |
483 | 483 | $this->registerAlias('ActivityManager', \OCP\Activity\IManager::class); |
484 | 484 | |
485 | - $this->registerService(\OCP\Activity\IEventMerger::class, function (Server $c) { |
|
485 | + $this->registerService(\OCP\Activity\IEventMerger::class, function(Server $c) { |
|
486 | 486 | return new \OC\Activity\EventMerger( |
487 | 487 | $c->getL10N('lib') |
488 | 488 | ); |
489 | 489 | }); |
490 | 490 | $this->registerAlias(IValidator::class, Validator::class); |
491 | 491 | |
492 | - $this->registerService(\OCP\IAvatarManager::class, function (Server $c) { |
|
492 | + $this->registerService(\OCP\IAvatarManager::class, function(Server $c) { |
|
493 | 493 | return new AvatarManager( |
494 | 494 | $c->getUserManager(), |
495 | 495 | $c->getAppDataDir('avatar'), |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | }); |
501 | 501 | $this->registerAlias('AvatarManager', \OCP\IAvatarManager::class); |
502 | 502 | |
503 | - $this->registerService(\OCP\ILogger::class, function (Server $c) { |
|
503 | + $this->registerService(\OCP\ILogger::class, function(Server $c) { |
|
504 | 504 | $logType = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
505 | 505 | $logger = Log::getLogClass($logType); |
506 | 506 | call_user_func(array($logger, 'init')); |
@@ -509,7 +509,7 @@ discard block |
||
509 | 509 | }); |
510 | 510 | $this->registerAlias('Logger', \OCP\ILogger::class); |
511 | 511 | |
512 | - $this->registerService(\OCP\BackgroundJob\IJobList::class, function (Server $c) { |
|
512 | + $this->registerService(\OCP\BackgroundJob\IJobList::class, function(Server $c) { |
|
513 | 513 | $config = $c->getConfig(); |
514 | 514 | return new \OC\BackgroundJob\JobList( |
515 | 515 | $c->getDatabaseConnection(), |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | }); |
520 | 520 | $this->registerAlias('JobList', \OCP\BackgroundJob\IJobList::class); |
521 | 521 | |
522 | - $this->registerService(\OCP\Route\IRouter::class, function (Server $c) { |
|
522 | + $this->registerService(\OCP\Route\IRouter::class, function(Server $c) { |
|
523 | 523 | $cacheFactory = $c->getMemCacheFactory(); |
524 | 524 | $logger = $c->getLogger(); |
525 | 525 | if ($cacheFactory->isAvailable()) { |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | }); |
532 | 532 | $this->registerAlias('Router', \OCP\Route\IRouter::class); |
533 | 533 | |
534 | - $this->registerService(\OCP\ISearch::class, function ($c) { |
|
534 | + $this->registerService(\OCP\ISearch::class, function($c) { |
|
535 | 535 | return new Search(); |
536 | 536 | }); |
537 | 537 | $this->registerAlias('Search', \OCP\ISearch::class); |
@@ -551,27 +551,27 @@ discard block |
||
551 | 551 | ); |
552 | 552 | }); |
553 | 553 | |
554 | - $this->registerService(\OCP\Security\ISecureRandom::class, function ($c) { |
|
554 | + $this->registerService(\OCP\Security\ISecureRandom::class, function($c) { |
|
555 | 555 | return new SecureRandom(); |
556 | 556 | }); |
557 | 557 | $this->registerAlias('SecureRandom', \OCP\Security\ISecureRandom::class); |
558 | 558 | |
559 | - $this->registerService(\OCP\Security\ICrypto::class, function (Server $c) { |
|
559 | + $this->registerService(\OCP\Security\ICrypto::class, function(Server $c) { |
|
560 | 560 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
561 | 561 | }); |
562 | 562 | $this->registerAlias('Crypto', \OCP\Security\ICrypto::class); |
563 | 563 | |
564 | - $this->registerService(\OCP\Security\IHasher::class, function (Server $c) { |
|
564 | + $this->registerService(\OCP\Security\IHasher::class, function(Server $c) { |
|
565 | 565 | return new Hasher($c->getConfig()); |
566 | 566 | }); |
567 | 567 | $this->registerAlias('Hasher', \OCP\Security\IHasher::class); |
568 | 568 | |
569 | - $this->registerService(\OCP\Security\ICredentialsManager::class, function (Server $c) { |
|
569 | + $this->registerService(\OCP\Security\ICredentialsManager::class, function(Server $c) { |
|
570 | 570 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
571 | 571 | }); |
572 | 572 | $this->registerAlias('CredentialsManager', \OCP\Security\ICredentialsManager::class); |
573 | 573 | |
574 | - $this->registerService(IDBConnection::class, function (Server $c) { |
|
574 | + $this->registerService(IDBConnection::class, function(Server $c) { |
|
575 | 575 | $systemConfig = $c->getSystemConfig(); |
576 | 576 | $factory = new \OC\DB\ConnectionFactory($systemConfig); |
577 | 577 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
@@ -585,7 +585,7 @@ discard block |
||
585 | 585 | }); |
586 | 586 | $this->registerAlias('DatabaseConnection', IDBConnection::class); |
587 | 587 | |
588 | - $this->registerService('HTTPHelper', function (Server $c) { |
|
588 | + $this->registerService('HTTPHelper', function(Server $c) { |
|
589 | 589 | $config = $c->getConfig(); |
590 | 590 | return new HTTPHelper( |
591 | 591 | $config, |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | ); |
594 | 594 | }); |
595 | 595 | |
596 | - $this->registerService(\OCP\Http\Client\IClientService::class, function (Server $c) { |
|
596 | + $this->registerService(\OCP\Http\Client\IClientService::class, function(Server $c) { |
|
597 | 597 | $user = \OC_User::getUser(); |
598 | 598 | $uid = $user ? $user : null; |
599 | 599 | return new ClientService( |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | }); |
604 | 604 | $this->registerAlias('HttpClientService', \OCP\Http\Client\IClientService::class); |
605 | 605 | |
606 | - $this->registerService(\OCP\Diagnostics\IEventLogger::class, function (Server $c) { |
|
606 | + $this->registerService(\OCP\Diagnostics\IEventLogger::class, function(Server $c) { |
|
607 | 607 | if ($c->getSystemConfig()->getValue('debug', false)) { |
608 | 608 | return new EventLogger(); |
609 | 609 | } else { |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | }); |
613 | 613 | $this->registerAlias('EventLogger', \OCP\Diagnostics\IEventLogger::class); |
614 | 614 | |
615 | - $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function (Server $c) { |
|
615 | + $this->registerService(\OCP\Diagnostics\IQueryLogger::class, function(Server $c) { |
|
616 | 616 | if ($c->getSystemConfig()->getValue('debug', false)) { |
617 | 617 | return new QueryLogger(); |
618 | 618 | } else { |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | }); |
622 | 622 | $this->registerAlias('QueryLogger', \OCP\Diagnostics\IQueryLogger::class); |
623 | 623 | |
624 | - $this->registerService(TempManager::class, function (Server $c) { |
|
624 | + $this->registerService(TempManager::class, function(Server $c) { |
|
625 | 625 | return new TempManager( |
626 | 626 | $c->getLogger(), |
627 | 627 | $c->getConfig() |
@@ -630,7 +630,7 @@ discard block |
||
630 | 630 | $this->registerAlias('TempManager', TempManager::class); |
631 | 631 | $this->registerAlias(ITempManager::class, TempManager::class); |
632 | 632 | |
633 | - $this->registerService(AppManager::class, function (Server $c) { |
|
633 | + $this->registerService(AppManager::class, function(Server $c) { |
|
634 | 634 | return new \OC\App\AppManager( |
635 | 635 | $c->getUserSession(), |
636 | 636 | $c->getAppConfig(), |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | $this->registerAlias('AppManager', AppManager::class); |
643 | 643 | $this->registerAlias(IAppManager::class, AppManager::class); |
644 | 644 | |
645 | - $this->registerService(\OCP\IDateTimeZone::class, function (Server $c) { |
|
645 | + $this->registerService(\OCP\IDateTimeZone::class, function(Server $c) { |
|
646 | 646 | return new DateTimeZone( |
647 | 647 | $c->getConfig(), |
648 | 648 | $c->getSession() |
@@ -650,7 +650,7 @@ discard block |
||
650 | 650 | }); |
651 | 651 | $this->registerAlias('DateTimeZone', \OCP\IDateTimeZone::class); |
652 | 652 | |
653 | - $this->registerService(\OCP\IDateTimeFormatter::class, function (Server $c) { |
|
653 | + $this->registerService(\OCP\IDateTimeFormatter::class, function(Server $c) { |
|
654 | 654 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
655 | 655 | |
656 | 656 | return new DateTimeFormatter( |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | }); |
661 | 661 | $this->registerAlias('DateTimeFormatter', \OCP\IDateTimeFormatter::class); |
662 | 662 | |
663 | - $this->registerService(\OCP\Files\Config\IUserMountCache::class, function (Server $c) { |
|
663 | + $this->registerService(\OCP\Files\Config\IUserMountCache::class, function(Server $c) { |
|
664 | 664 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
665 | 665 | $listener = new UserMountCacheListener($mountCache); |
666 | 666 | $listener->listen($c->getUserManager()); |
@@ -668,10 +668,10 @@ discard block |
||
668 | 668 | }); |
669 | 669 | $this->registerAlias('UserMountCache', \OCP\Files\Config\IUserMountCache::class); |
670 | 670 | |
671 | - $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function (Server $c) { |
|
671 | + $this->registerService(\OCP\Files\Config\IMountProviderCollection::class, function(Server $c) { |
|
672 | 672 | $loader = \OC\Files\Filesystem::getLoader(); |
673 | 673 | $mountCache = $c->query('UserMountCache'); |
674 | - $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
674 | + $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
|
675 | 675 | |
676 | 676 | // builtin providers |
677 | 677 | |
@@ -684,14 +684,14 @@ discard block |
||
684 | 684 | }); |
685 | 685 | $this->registerAlias('MountConfigManager', \OCP\Files\Config\IMountProviderCollection::class); |
686 | 686 | |
687 | - $this->registerService('IniWrapper', function ($c) { |
|
687 | + $this->registerService('IniWrapper', function($c) { |
|
688 | 688 | return new IniGetWrapper(); |
689 | 689 | }); |
690 | - $this->registerService('AsyncCommandBus', function (Server $c) { |
|
690 | + $this->registerService('AsyncCommandBus', function(Server $c) { |
|
691 | 691 | $jobList = $c->getJobList(); |
692 | 692 | return new AsyncBus($jobList); |
693 | 693 | }); |
694 | - $this->registerService('TrustedDomainHelper', function ($c) { |
|
694 | + $this->registerService('TrustedDomainHelper', function($c) { |
|
695 | 695 | return new TrustedDomainHelper($this->getConfig()); |
696 | 696 | }); |
697 | 697 | $this->registerService('Throttler', function(Server $c) { |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | $c->getConfig() |
703 | 703 | ); |
704 | 704 | }); |
705 | - $this->registerService('IntegrityCodeChecker', function (Server $c) { |
|
705 | + $this->registerService('IntegrityCodeChecker', function(Server $c) { |
|
706 | 706 | // IConfig and IAppManager requires a working database. This code |
707 | 707 | // might however be called when ownCloud is not yet setup. |
708 | - if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
708 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
709 | 709 | $config = $c->getConfig(); |
710 | 710 | $appManager = $c->getAppManager(); |
711 | 711 | } else { |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | $c->getTempManager() |
724 | 724 | ); |
725 | 725 | }); |
726 | - $this->registerService(\OCP\IRequest::class, function ($c) { |
|
726 | + $this->registerService(\OCP\IRequest::class, function($c) { |
|
727 | 727 | if (isset($this['urlParams'])) { |
728 | 728 | $urlParams = $this['urlParams']; |
729 | 729 | } else { |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | }); |
760 | 760 | $this->registerAlias('Request', \OCP\IRequest::class); |
761 | 761 | |
762 | - $this->registerService(\OCP\Mail\IMailer::class, function (Server $c) { |
|
762 | + $this->registerService(\OCP\Mail\IMailer::class, function(Server $c) { |
|
763 | 763 | return new Mailer( |
764 | 764 | $c->getConfig(), |
765 | 765 | $c->getLogger(), |
@@ -773,14 +773,14 @@ discard block |
||
773 | 773 | $this->registerService('LDAPProvider', function(Server $c) { |
774 | 774 | $config = $c->getConfig(); |
775 | 775 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
776 | - if(is_null($factoryClass)) { |
|
776 | + if (is_null($factoryClass)) { |
|
777 | 777 | throw new \Exception('ldapProviderFactory not set'); |
778 | 778 | } |
779 | 779 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
780 | 780 | $factory = new $factoryClass($this); |
781 | 781 | return $factory->getLDAPProvider(); |
782 | 782 | }); |
783 | - $this->registerService('LockingProvider', function (Server $c) { |
|
783 | + $this->registerService('LockingProvider', function(Server $c) { |
|
784 | 784 | $ini = $c->getIniWrapper(); |
785 | 785 | $config = $c->getConfig(); |
786 | 786 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
@@ -796,37 +796,37 @@ discard block |
||
796 | 796 | return new NoopLockingProvider(); |
797 | 797 | }); |
798 | 798 | |
799 | - $this->registerService(\OCP\Files\Mount\IMountManager::class, function () { |
|
799 | + $this->registerService(\OCP\Files\Mount\IMountManager::class, function() { |
|
800 | 800 | return new \OC\Files\Mount\Manager(); |
801 | 801 | }); |
802 | 802 | $this->registerAlias('MountManager', \OCP\Files\Mount\IMountManager::class); |
803 | 803 | |
804 | - $this->registerService(\OCP\Files\IMimeTypeDetector::class, function (Server $c) { |
|
804 | + $this->registerService(\OCP\Files\IMimeTypeDetector::class, function(Server $c) { |
|
805 | 805 | return new \OC\Files\Type\Detection( |
806 | 806 | $c->getURLGenerator(), |
807 | 807 | \OC::$configDir, |
808 | - \OC::$SERVERROOT . '/resources/config/' |
|
808 | + \OC::$SERVERROOT.'/resources/config/' |
|
809 | 809 | ); |
810 | 810 | }); |
811 | 811 | $this->registerAlias('MimeTypeDetector', \OCP\Files\IMimeTypeDetector::class); |
812 | 812 | |
813 | - $this->registerService(\OCP\Files\IMimeTypeLoader::class, function (Server $c) { |
|
813 | + $this->registerService(\OCP\Files\IMimeTypeLoader::class, function(Server $c) { |
|
814 | 814 | return new \OC\Files\Type\Loader( |
815 | 815 | $c->getDatabaseConnection() |
816 | 816 | ); |
817 | 817 | }); |
818 | 818 | $this->registerAlias('MimeTypeLoader', \OCP\Files\IMimeTypeLoader::class); |
819 | 819 | |
820 | - $this->registerService(\OCP\Notification\IManager::class, function (Server $c) { |
|
820 | + $this->registerService(\OCP\Notification\IManager::class, function(Server $c) { |
|
821 | 821 | return new Manager( |
822 | 822 | $c->query(IValidator::class) |
823 | 823 | ); |
824 | 824 | }); |
825 | 825 | $this->registerAlias('NotificationManager', \OCP\Notification\IManager::class); |
826 | 826 | |
827 | - $this->registerService(\OC\CapabilitiesManager::class, function (Server $c) { |
|
827 | + $this->registerService(\OC\CapabilitiesManager::class, function(Server $c) { |
|
828 | 828 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
829 | - $manager->registerCapability(function () use ($c) { |
|
829 | + $manager->registerCapability(function() use ($c) { |
|
830 | 830 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
831 | 831 | }); |
832 | 832 | return $manager; |
@@ -882,13 +882,13 @@ discard block |
||
882 | 882 | $cacheFactory->createLocal('SCSS') |
883 | 883 | ); |
884 | 884 | }); |
885 | - $this->registerService(EventDispatcher::class, function () { |
|
885 | + $this->registerService(EventDispatcher::class, function() { |
|
886 | 886 | return new EventDispatcher(); |
887 | 887 | }); |
888 | 888 | $this->registerAlias('EventDispatcher', EventDispatcher::class); |
889 | 889 | $this->registerAlias(EventDispatcherInterface::class, EventDispatcher::class); |
890 | 890 | |
891 | - $this->registerService('CryptoWrapper', function (Server $c) { |
|
891 | + $this->registerService('CryptoWrapper', function(Server $c) { |
|
892 | 892 | // FIXME: Instantiiated here due to cyclic dependency |
893 | 893 | $request = new Request( |
894 | 894 | [ |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | $request |
914 | 914 | ); |
915 | 915 | }); |
916 | - $this->registerService('CsrfTokenManager', function (Server $c) { |
|
916 | + $this->registerService('CsrfTokenManager', function(Server $c) { |
|
917 | 917 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
918 | 918 | |
919 | 919 | return new CsrfTokenManager( |
@@ -921,10 +921,10 @@ discard block |
||
921 | 921 | $c->query(SessionStorage::class) |
922 | 922 | ); |
923 | 923 | }); |
924 | - $this->registerService(SessionStorage::class, function (Server $c) { |
|
924 | + $this->registerService(SessionStorage::class, function(Server $c) { |
|
925 | 925 | return new SessionStorage($c->getSession()); |
926 | 926 | }); |
927 | - $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function (Server $c) { |
|
927 | + $this->registerService(\OCP\Security\IContentSecurityPolicyManager::class, function(Server $c) { |
|
928 | 928 | return new ContentSecurityPolicyManager(); |
929 | 929 | }); |
930 | 930 | $this->registerAlias('ContentSecurityPolicyManager', \OCP\Security\IContentSecurityPolicyManager::class); |
@@ -975,29 +975,29 @@ discard block |
||
975 | 975 | ); |
976 | 976 | return $manager; |
977 | 977 | }); |
978 | - $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
|
978 | + $this->registerService(\OC\Files\AppData\Factory::class, function(Server $c) { |
|
979 | 979 | return new \OC\Files\AppData\Factory( |
980 | 980 | $c->getRootFolder(), |
981 | 981 | $c->getSystemConfig() |
982 | 982 | ); |
983 | 983 | }); |
984 | 984 | |
985 | - $this->registerService('LockdownManager', function (Server $c) { |
|
985 | + $this->registerService('LockdownManager', function(Server $c) { |
|
986 | 986 | return new LockdownManager(function() use ($c) { |
987 | 987 | return $c->getSession(); |
988 | 988 | }); |
989 | 989 | }); |
990 | 990 | |
991 | - $this->registerService(\OCP\OCS\IDiscoveryService::class, function (Server $c) { |
|
991 | + $this->registerService(\OCP\OCS\IDiscoveryService::class, function(Server $c) { |
|
992 | 992 | return new DiscoveryService($c->getMemCacheFactory(), $c->getHTTPClientService()); |
993 | 993 | }); |
994 | 994 | |
995 | - $this->registerService(ICloudIdManager::class, function (Server $c) { |
|
995 | + $this->registerService(ICloudIdManager::class, function(Server $c) { |
|
996 | 996 | return new CloudIdManager(); |
997 | 997 | }); |
998 | 998 | |
999 | 999 | /* To trick DI since we don't extend the DIContainer here */ |
1000 | - $this->registerService(CleanPreviewsBackgroundJob::class, function (Server $c) { |
|
1000 | + $this->registerService(CleanPreviewsBackgroundJob::class, function(Server $c) { |
|
1001 | 1001 | return new CleanPreviewsBackgroundJob( |
1002 | 1002 | $c->getRootFolder(), |
1003 | 1003 | $c->getLogger(), |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | $this->registerAlias(\OCP\AppFramework\Utility\ITimeFactory::class, \OC\AppFramework\Utility\TimeFactory::class); |
1013 | 1013 | $this->registerAlias('TimeFactory', \OCP\AppFramework\Utility\ITimeFactory::class); |
1014 | 1014 | |
1015 | - $this->registerService(Defaults::class, function (Server $c) { |
|
1015 | + $this->registerService(Defaults::class, function(Server $c) { |
|
1016 | 1016 | return new Defaults( |
1017 | 1017 | $c->getThemingDefaults() |
1018 | 1018 | ); |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | * @deprecated since 9.2.0 use IAppData |
1165 | 1165 | */ |
1166 | 1166 | public function getAppFolder() { |
1167 | - $dir = '/' . \OC_App::getCurrentApp(); |
|
1167 | + $dir = '/'.\OC_App::getCurrentApp(); |
|
1168 | 1168 | $root = $this->getRootFolder(); |
1169 | 1169 | if (!$root->nodeExists($dir)) { |
1170 | 1170 | $folder = $root->newFolder($dir); |
@@ -35,39 +35,39 @@ discard block |
||
35 | 35 | |
36 | 36 | $application = new Application(); |
37 | 37 | $application->registerRoutes($this, [ |
38 | - 'routes' => [ |
|
39 | - ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | - ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | - ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | - ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | - ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | - ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | - ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | - ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | - ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | - ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | - ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | - ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | - ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | - ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
53 | - ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
54 | - ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
55 | - ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
56 | - ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
57 | - ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
58 | - ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
59 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
60 | - ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
61 | - ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
62 | - ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
63 | - ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
64 | - ], |
|
65 | - 'ocs' => [ |
|
66 | - ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
67 | - ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
68 | - ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
69 | - ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
70 | - ], |
|
38 | + 'routes' => [ |
|
39 | + ['name' => 'lost#email', 'url' => '/lostpassword/email', 'verb' => 'POST'], |
|
40 | + ['name' => 'lost#resetform', 'url' => '/lostpassword/reset/form/{token}/{userId}', 'verb' => 'GET'], |
|
41 | + ['name' => 'lost#setPassword', 'url' => '/lostpassword/set/{token}/{userId}', 'verb' => 'POST'], |
|
42 | + ['name' => 'user#getDisplayNames', 'url' => '/displaynames', 'verb' => 'POST'], |
|
43 | + ['name' => 'avatar#getAvatar', 'url' => '/avatar/{userId}/{size}', 'verb' => 'GET'], |
|
44 | + ['name' => 'avatar#deleteAvatar', 'url' => '/avatar/', 'verb' => 'DELETE'], |
|
45 | + ['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'], |
|
46 | + ['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'], |
|
47 | + ['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'], |
|
48 | + ['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'], |
|
49 | + ['name' => 'login#confirmPassword', 'url' => '/login/confirm', 'verb' => 'POST'], |
|
50 | + ['name' => 'login#showLoginForm', 'url' => '/login', 'verb' => 'GET'], |
|
51 | + ['name' => 'login#logout', 'url' => '/logout', 'verb' => 'GET'], |
|
52 | + ['name' => 'ClientFlowLogin#showAuthPickerPage', 'url' => '/login/flow', 'verb' => 'GET'], |
|
53 | + ['name' => 'ClientFlowLogin#redirectPage', 'url' => '/login/flow/redirect', 'verb' => 'GET'], |
|
54 | + ['name' => 'ClientFlowLogin#generateAppPassword', 'url' => '/login/flow', 'verb' => 'POST'], |
|
55 | + ['name' => 'TwoFactorChallenge#selectChallenge', 'url' => '/login/selectchallenge', 'verb' => 'GET'], |
|
56 | + ['name' => 'TwoFactorChallenge#showChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'GET'], |
|
57 | + ['name' => 'TwoFactorChallenge#solveChallenge', 'url' => '/login/challenge/{challengeProviderId}', 'verb' => 'POST'], |
|
58 | + ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], |
|
59 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], |
|
60 | + ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], |
|
61 | + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], |
|
62 | + ['name' => 'Js#getJs', 'url' => '/js/{appName}/{fileName}', 'verb' => 'GET'], |
|
63 | + ['name' => 'contactsMenu#index', 'url' => '/contactsmenu/contacts', 'verb' => 'POST'], |
|
64 | + ], |
|
65 | + 'ocs' => [ |
|
66 | + ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], |
|
67 | + ['root' => '', 'name' => 'OCS#getConfig', 'url' => '/config', 'verb' => 'GET'], |
|
68 | + ['root' => '/person', 'name' => 'OCS#personCheck', 'url' => '/check', 'verb' => 'POST'], |
|
69 | + ['root' => '/identityproof', 'name' => 'OCS#getIdentityProof', 'url' => '/key/{cloudId}', 'verb' => 'GET'], |
|
70 | + ], |
|
71 | 71 | ]); |
72 | 72 | |
73 | 73 | // Post installation check |
@@ -76,62 +76,62 @@ discard block |
||
76 | 76 | // Core ajax actions |
77 | 77 | // Search |
78 | 78 | $this->create('search_ajax_search', '/core/search') |
79 | - ->actionInclude('core/search/ajax/search.php'); |
|
79 | + ->actionInclude('core/search/ajax/search.php'); |
|
80 | 80 | // Routing |
81 | 81 | $this->create('core_ajax_update', '/core/ajax/update.php') |
82 | - ->actionInclude('core/ajax/update.php'); |
|
82 | + ->actionInclude('core/ajax/update.php'); |
|
83 | 83 | |
84 | 84 | // File routes |
85 | 85 | $this->create('files.viewcontroller.showFile', '/f/{fileid}')->action(function($urlParams) { |
86 | - $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
87 | - $app->dispatch('ViewController', 'index'); |
|
86 | + $app = new \OCA\Files\AppInfo\Application($urlParams); |
|
87 | + $app->dispatch('ViewController', 'index'); |
|
88 | 88 | }); |
89 | 89 | |
90 | 90 | // Call routes |
91 | 91 | $this->create('spreed.pagecontroller.showCall', '/call/{token}')->action(function($urlParams) { |
92 | - if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
93 | - $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
94 | - $app->dispatch('PageController', 'index'); |
|
95 | - } else { |
|
96 | - throw new \OC\HintException('App spreed is not enabled'); |
|
97 | - } |
|
92 | + if (class_exists(\OCA\Spreed\AppInfo\Application::class, false)) { |
|
93 | + $app = new \OCA\Spreed\AppInfo\Application($urlParams); |
|
94 | + $app->dispatch('PageController', 'index'); |
|
95 | + } else { |
|
96 | + throw new \OC\HintException('App spreed is not enabled'); |
|
97 | + } |
|
98 | 98 | }); |
99 | 99 | |
100 | 100 | // Sharing routes |
101 | 101 | $this->create('files_sharing.sharecontroller.showShare', '/s/{token}')->action(function($urlParams) { |
102 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
103 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
104 | - $app->dispatch('ShareController', 'showShare'); |
|
105 | - } else { |
|
106 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
107 | - } |
|
102 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
103 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
104 | + $app->dispatch('ShareController', 'showShare'); |
|
105 | + } else { |
|
106 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
107 | + } |
|
108 | 108 | }); |
109 | 109 | $this->create('files_sharing.sharecontroller.authenticate', '/s/{token}/authenticate')->post()->action(function($urlParams) { |
110 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
111 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
112 | - $app->dispatch('ShareController', 'authenticate'); |
|
113 | - } else { |
|
114 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
115 | - } |
|
110 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
111 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
112 | + $app->dispatch('ShareController', 'authenticate'); |
|
113 | + } else { |
|
114 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
115 | + } |
|
116 | 116 | }); |
117 | 117 | $this->create('files_sharing.sharecontroller.showAuthenticate', '/s/{token}/authenticate')->get()->action(function($urlParams) { |
118 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
119 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
120 | - $app->dispatch('ShareController', 'showAuthenticate'); |
|
121 | - } else { |
|
122 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
123 | - } |
|
118 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
119 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
120 | + $app->dispatch('ShareController', 'showAuthenticate'); |
|
121 | + } else { |
|
122 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
123 | + } |
|
124 | 124 | }); |
125 | 125 | $this->create('files_sharing.sharecontroller.downloadShare', '/s/{token}/download')->get()->action(function($urlParams) { |
126 | - if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
127 | - $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
128 | - $app->dispatch('ShareController', 'downloadShare'); |
|
129 | - } else { |
|
130 | - throw new \OC\HintException('App file sharing is not enabled'); |
|
131 | - } |
|
126 | + if (class_exists(\OCA\Files_Sharing\AppInfo\Application::class, false)) { |
|
127 | + $app = new \OCA\Files_Sharing\AppInfo\Application($urlParams); |
|
128 | + $app->dispatch('ShareController', 'downloadShare'); |
|
129 | + } else { |
|
130 | + throw new \OC\HintException('App file sharing is not enabled'); |
|
131 | + } |
|
132 | 132 | }); |
133 | 133 | |
134 | 134 | // used for heartbeat |
135 | 135 | $this->create('heartbeat', '/heartbeat')->action(function(){ |
136 | - // do nothing |
|
136 | + // do nothing |
|
137 | 137 | }); |