|
7 | 7 |
|
8 | 8 | namespace OCA\TermsOfService\AppInfo; |
9 | 9 |
|
10 | | -use Exception; |
11 | 10 | use OC\Files\Filesystem; |
12 | 11 | use OCA\DAV\Events\SabrePluginAddEvent; |
13 | 12 | use OCA\Registration\Events\PassedFormEvent; |
@@ -120,38 +119,35 @@ public function registerFrontend(IRequest $request, IAppConfig $appConfig, IUser |
120 | 119 | } |
121 | 120 |
|
122 | 121 | public function addStorageWrapper(): void { |
| 122 | + $request = \OCP\Server::get(IRequest::class); |
| 123 | + $checker = \OCP\Server::get(Checker::class); |
| 124 | + |
123 | 125 | Filesystem::addStorageWrapper( |
124 | | - 'terms_of_service', $this->addStorageWrapperCallback(...), -10 |
| 126 | + 'terms_of_service', function (string $mountPoint, IStorage $storage) use ($request, $checker): IStorage { |
| 127 | + /** @psalm-suppress UndefinedClass */ |
| 128 | + if (!\OC::$CLI) { |
| 129 | + try { |
| 130 | + return new StorageWrapper( |
| 131 | + [ |
| 132 | + 'storage' => $storage, |
| 133 | + 'mountPoint' => $mountPoint, |
| 134 | + 'request' => $request, |
| 135 | + 'checker' => $checker, |
| 136 | + ] |
| 137 | + ); |
| 138 | + } catch (ContainerExceptionInterface $e) { |
| 139 | + \OCP\Server::get(LoggerInterface::class)->error( |
| 140 | + $e->getMessage(), |
| 141 | + ['exception' => $e] |
| 142 | + ); |
| 143 | + } |
| 144 | + } |
| 145 | + |
| 146 | + return $storage; |
| 147 | + }, -10 |
125 | 148 | ); |
126 | 149 | } |
127 | 150 |
|
128 | | - /** |
129 | | - * @return StorageWrapper|IStorage |
130 | | - * @throws Exception |
131 | | - */ |
132 | | - public function addStorageWrapperCallback(string $mountPoint, IStorage $storage): IStorage { |
133 | | - /** @psalm-suppress UndefinedClass */ |
134 | | - if (!\OC::$CLI) { |
135 | | - try { |
136 | | - return new StorageWrapper( |
137 | | - [ |
138 | | - 'storage' => $storage, |
139 | | - 'mountPoint' => $mountPoint, |
140 | | - 'request' => \OCP\Server::get(IRequest::class), |
141 | | - 'checker' => \OCP\Server::get(Checker::class), |
142 | | - ] |
143 | | - ); |
144 | | - } catch (ContainerExceptionInterface $e) { |
145 | | - \OCP\Server::get(LoggerInterface::class)->error( |
146 | | - $e->getMessage(), |
147 | | - ['exception' => $e] |
148 | | - ); |
149 | | - } |
150 | | - } |
151 | | - |
152 | | - return $storage; |
153 | | - } |
154 | | - |
155 | 151 | public function registerNotifier(IManager $notificationManager): void { |
156 | 152 | $notificationManager->registerNotifierService(Notifier::class); |
157 | 153 | } |
|
0 commit comments